Skip to content

Commit

Permalink
fix: soft masking for SubMesheUI (TextMeshProUGUI) may not display co…
Browse files Browse the repository at this point in the history
…rrectly

close #216
  • Loading branch information
mob-sakai committed Dec 22, 2024
1 parent 9e1a107 commit d417c06
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Packages/src/Runtime/SoftMaskable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,19 @@ private void OnEnable()
_shouldRecalculateStencil = true;
if (TryGetComponent(out _graphic))
{
// Check if the graphic is before this component.
var components = InternalListPool<Component>.Rent();
GetComponents(components);
var gIndex = components.IndexOf(_graphic);
var sIndex = components.IndexOf(this);
InternalListPool<Component>.Return(ref components);
if (sIndex < gIndex)
{
gameObject.AddComponent<SoftMaskable>();
Misc.Destroy(this);
return;
}

_graphic.SetMaterialDirty();
}
else
Expand Down

0 comments on commit d417c06

Please sign in to comment.