From d417c060596ab58179d6b3e622bd40309b49a3b8 Mon Sep 17 00:00:00 2001 From: mob-sakai <12690315+mob-sakai@users.noreply.github.com> Date: Sun, 22 Dec 2024 09:46:06 +0900 Subject: [PATCH] fix: soft masking for SubMesheUI (TextMeshProUGUI) may not display correctly close #216 --- Packages/src/Runtime/SoftMaskable.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Packages/src/Runtime/SoftMaskable.cs b/Packages/src/Runtime/SoftMaskable.cs index 69402a5..3708257 100755 --- a/Packages/src/Runtime/SoftMaskable.cs +++ b/Packages/src/Runtime/SoftMaskable.cs @@ -126,6 +126,19 @@ private void OnEnable() _shouldRecalculateStencil = true; if (TryGetComponent(out _graphic)) { + // Check if the graphic is before this component. + var components = InternalListPool.Rent(); + GetComponents(components); + var gIndex = components.IndexOf(_graphic); + var sIndex = components.IndexOf(this); + InternalListPool.Return(ref components); + if (sIndex < gIndex) + { + gameObject.AddComponent(); + Misc.Destroy(this); + return; + } + _graphic.SetMaterialDirty(); } else