If it helps, the fonts I’m using are using fallback fonts, to support multiple languages and I have Multi Atlas Texture enabled as well.
Running Unity 2019.4.16f1 with TMP ver: 2.1.3
I am aware of this issue which is the result of font assets using multi atlas textures where the internal index to track the texture index is out of sync. More specifically, the font asset glyph table still has glyphs referencing an index other than zero (ie. pointing to another atlas texture) where the texture at this index is no longer present.
Using the context menu Reset on the font assets that are producing this error will resolve this issue. Unfortunately, I have been unable to figure out what causes a font asset to get into this state where again, the character and glyph table contain glyphs that reference those other atlas textures which for some reason have all been removed / deleted.
If you can think of anything special in your workflow / handling of the font assets that might lead to this issue please let me know. Something is getting these font assets in this state but I am not sure what?
Could it have anything to do with masks?
What would cause textures to be removed, don’t they only get added?
If you can’t fix it is there a way you could detect and recover from it for when it happens in production other than restarting the game?
I don’t think the use of either masking type would affect this.
The issue is strange in the sense that the new character and glyph data does correctly gets saved / serialized but not those additional textures for some reason.
I could detect when the atlas index is greater than the # of textures where I would then Reset the font asset but that is pretty drastic. I would prefer to first figure out how we get into that state and then apply the correct solution instead of the Reset which is like a Nuke.
P.S. I suspect this issue occurs in the Editor while working on the project and not in a build / runtime.
UI Mask
Could it have anything to do with having it on a different Canvas.
Happened again to me this morning, here the error from within the editor:
NullReferenceException: Object reference not set to an instance of an object
TMPro.TextMeshProUGUI.UpdateSDFScale (System.Single scaleDelta) (at Library/PackageCache/com.unity.textmeshpro@2.1.3/Scripts/Runtime/TMPro_UGUI_Private.cs:4593)
TMPro.TextMeshProUGUI.InternalUpdate () (at Library/PackageCache/com.unity.textmeshpro@2.1.3/Scripts/Runtime/TMPro_UGUI_Private.cs:1573)
TMPro.TMP_UpdateManager.DoRebuilds () (at Library/PackageCache/com.unity.textmeshpro@2.1.3/Scripts/Runtime/TMP_UpdateManager.cs:153)
UnityEngine.Canvas.SendWillRenderCanvases () (at <6df2bf6e7bc1499cbb0f04556df8b702>:0)
UnityEngine.Camera:Render()
I totally miss read your initial post… the error occurs in the UpdateSDFScale as your initial Stack Trace clearly indicates.
We could add a null check on the “meshInfo.uvs2” right before line 4593 but that is like putting a Band-Aid on a rash. This won’t allow us to figure out why the material count and material index at this point is referencing a meshInfo whose UV2 is null. I need to figure out what leads to this condition to implement a proper fix.
The issue could most certainly be related to using a UI Mask which requires the creation / use of material instances for the masking. Any reason you are using UI Mask instead of a RectMask2D? Are you using some masking shape or something?
What do you mean by using a different Canvas?
Does this happen on object instantiation or moving an object in the scene hierarchy?
BTW: Is the scale of this text object changing in its life cycle or any of its parents?
As in a Canvas within a Canvas (for performance so it doesn’t re-build all UI outside of the Canvas etc.)
Yes, the parent’s scale changes.
When I instantiate the prefab it starts off alpha 0 and a scale of 0.1 and then quickly scales up to 1 and alpha to 1 to get a nice pop in effect. After a few seconds, I then fade it back out and scale it back down and destroy it.
I realize this is an old post at this point, but I’m having this same problem and this is pretty much the only result Google has to provide about it. Was this ever fixed in any way? This is in live production release on Windows and Mac for us, not in the Editor. My objects are also animating, similar to @SniperED007 last stated. Sometimes objects will also appear very briefly and then are hidden/changed quickly. We don’t have a “canvas in a canvas”, although the scene does have multiple canvas. It isn’t clear what the users may be seeing when this crash happens.