Hi everyone, I hope someone can help me with this issue I’m facing in my project.
I’m using TextMeshPro with sprite icons, referencing a Sprite Atlas set in the TMP Settings. When I update a text field that contains inline sprite tags (e.g. <sprite name="icon">), TMP correctly creates the SubMeshUI GameObject and displays the icon as expected.
However, the problem appears when I update the text again with new data. The new text is applied, but the previous sprites are not properly cleared, and they still appear overlapping the new ones, even if the new text doesn’t include them. It seems like the SubMeshUI is not being properly reset or cleared when the TMP text is updated.
-
First applying the text with sprites works correclty.
-
Then when I update the text with new data, you can see the previous icons are not cleaning properly.
I’ve tried forcing a ForceMeshUpdate() and even disabling/enabling the component, but nothing has worked so far.
If anyone has encountered a similar issue or knows how to fully clear the SubMeshUI or reset the sprite state in TMP, I would really appreciate your help!
Unity Version: 6000.0.47
I tested this in 6000.0.47f1 but I wasn’t able to get a reproduction, the inline sprites were cleared properly on my end after updating the text. Could you please report a bug from within the Editor by selecting “Help → Report a Bug…” and attach your project so our Customer QA team can take a look? I’d also appreciate it if you could share the ticket ID (IN-XXXXX) after submitting the report.
Update / Partial Fix Found
We found a workaround for this issue in our project. Apparently, the SubMeshUI was triggering the bug when the text included a <sprite> tag, but not when the text changed afterward or removed the sprite.
To fix this behavior, we now force the update every time we set new text data, using the following steps:
- Check if the text contains
"<sprite".
- Call
ForceMeshUpdate() on the TextMeshPro component.
- Manually destroy the SubMeshUI GameObject (if it exists).
- Update the vertex data using
UpdateVertexData().
- Rebuild the layout using
LayoutRebuilder.ForceRebuildLayoutImmediate() on the parent.
It may not be a deep or permanent fix, but in our case, it successfully clears out the previous icons and prevents the overlapping issue.
Hope this helps someone!