fix: select TMP submesh by mesh before material

This commit is contained in:
조영록
2026-06-17 16:54:50 +09:00
committed by mob-sakai
parent ae483ec577
commit f538ef2cba
+14 -3
View File
@@ -239,7 +239,7 @@ namespace Coffee.UIEffects
}
else
{
var subMeshUI = GetSubMeshUI(subMeshes, meshInfo.material, i - 1);
var subMeshUI = GetSubMeshUI(subMeshes, meshInfo.material, meshInfo.mesh, i - 1);
if (subMeshUI)
{
subMeshUI.canvasRenderer.SetMesh(s_Mesh);
@@ -269,7 +269,7 @@ namespace Coffee.UIEffects
modifier.ModifyMesh(s_VertexHelper);
}
var subMeshUI = GetSubMeshUI(subMeshes, meshInfo.material, i - 1);
var subMeshUI = GetSubMeshUI(subMeshes, meshInfo.material, meshInfo.mesh, i - 1);
if (!subMeshUI) break;
// fix: TMP Text sprite submesh lost when changing fontMaterial (#368)
@@ -323,12 +323,23 @@ namespace Coffee.UIEffects
Misc.QueuePlayerLoopUpdate();
}
private static TMP_SubMeshUI GetSubMeshUI(List<TMP_SubMeshUI> subMeshes, Material material, int start)
private static TMP_SubMeshUI GetSubMeshUI(List<TMP_SubMeshUI> subMeshes, Material material, Mesh mesh, int start)
{
var count = subMeshes.Count;
if (mesh)
{
for (var j = 0; j < count; j++)
{
var s = subMeshes[(j + start + count) % count];
if (!s) continue;
if (s.mesh == mesh) return s;
}
}
for (var j = 0; j < count; j++)
{
var s = subMeshes[(j + start + count) % count];
if (!s) continue;
if (s.sharedMaterial == material) return s;
}