Failed updating mesh in submeshUI left-over

Hello,

We had a weird bug where a sprite was missing in the middle of a sentence in Japanese. When running the game in the editor we discovered an error message that said, if I recall correctly, that indices where referencing out of bound vertices and that UVs had a different number of entries than vertices. I searched through the code but could not understand what was going on.

I started working on a repro project but, surprisingly, the issue never occurred in the test project. So I started looking for differences. After toying around with enabling/disabling the text mesh pro ugui object in the real case, I noticed the bug was sometimes disappearing by itself.

I finally found a difference: we had a TMP SubMeshUI leftover in the scene. In the test scene, when setting the text, two SubMeshUIs were properly created to display the sprite and a fallback font. In the real case, no new SubMeshUI was created, only was there, properly updated to display the text but no new one was created to display the sprite.

I deleted that TMP SubMeshUI leftover and now I don’t have the bug anymore. I deleted all the TMP SubMeshUIs from the whole game actually, since they’re created on a needed basis. Some popped up again, obviously, but I hope they won’t cause any trouble.

Assets used to try to repro: http://manufacture43.com/submeshbugassets.zip
Text used to try to repro: “シールドが低下!<color=#FF634A>ミサイル<sprite=27>であの<color=#06E123>緑のサーペントをDrainだ!”

Honest opinion: these TMP_SubMeshUI things are a mess. IMHO, they should never be serialized with the scene and not even displayed to the user: Unity - Scripting API: HideFlags.HideAndDontSave

I already made the change to no longer have the sub mesh objects serialized.

They will continue to be visible / accessible since there is some functionality exposed in the inspector.

P.S. I considered removing the Sub Mesh objects all together in favor of using submeshes but that resulted in a degradation of performance due to the triangle / indices having to be updated every time the text changes but more importantly because these sub mesh objects allow different renderers to be used where parts of the text could be using SpriteRenderers or Renderers to render SVG, etc… Ie. much more flexible.

1 Like