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;