From 59874ddffe356f927dc8ff9b157c54043e149522 Mon Sep 17 00:00:00 2001 From: mob-sakai <12690315+mob-sakai@users.noreply.github.com> Date: Thu, 25 Sep 2025 19:26:50 +0900 Subject: [PATCH] fix: TMP Text sprite submesh lost when changing fontMaterial close #368 --- Packages/src/Runtime/Utilities/TmpProxy.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Packages/src/Runtime/Utilities/TmpProxy.cs b/Packages/src/Runtime/Utilities/TmpProxy.cs index 4351c10..3709801 100644 --- a/Packages/src/Runtime/Utilities/TmpProxy.cs +++ b/Packages/src/Runtime/Utilities/TmpProxy.cs @@ -260,7 +260,16 @@ namespace Coffee.UIEffects var subMeshUI = GetSubMeshUI(subMeshes, meshInfo.material, i - 1); if (!subMeshUI) break; - var replica = subMeshUI.GetOrAddComponent(); + // fix: TMP Text sprite submesh lost when changing fontMaterial (#368) + if (!subMeshUI.TryGetComponent(out var replica)) + { + replica = subMeshUI.gameObject.AddComponent(); + textMeshProUGUI.RegisterDirtyMaterialCallback(() => + { + if (subMeshUI) subMeshUI.SetMaterialDirty(); + }); + } + if (effect is UIEffect pEffect && pEffect.isActiveAndEnabled) { replica.target = pEffect;