TextMesh Pro error when quitting game - The object of type 'Material' has been destroyed but...

MissingReferenceException: The object of type ‘Material’ has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
UnityEngine.Object.get_name () (at /Users/bokken/buildslave/unity/build/Runtime/Export/Scripting/UnityEngineObject.bindings.cs:194)
TMPro.TMP_SubMeshUI.AddSubTextObject (TMPro.TextMeshProUGUI textComponent, TMPro.MaterialReference materialReference) (at Library/PackageCache/com.unity.textmeshpro@3.0.6/Scripts/Runtime/TMP_SubMeshUI.cs:215)

I’m Using Unity 2020.3.11f1, with the latest TextMesh Pro (3.0.6) and the TMP Essential Resources imported.

If it matters, I’m doing additive scene loading, and each scene has it’s own Screen Space - Camera canvas. When a scene is additively loaded, I disable the scene camera and set the Canvas’s camera to the main scene camera.

The errors occur only when exiting the game in Play mode in the editor - I haven’t tried a build.

the thing is I don’t have any script that is doing anything when I stop play mode except maybe a Pointer Down event listener on a UI button.

Any ideas on what I can do the fix this, or why it is happening?

1 Like

Hello, I have the same problem. Have you solved this problem? May I ask how to solve it? Thanks!

same

Same

Heya! I was having the same problem recently, it seemed to be happening because of certain characters being used in the text. They would cause the textmeshpro to create a TMP_SubMeshUI as children of the specified TextMeshPro object, wich would auto-delete itself after stopping play.

The specific characters being used in my case were Double Quotation Marks ", and Brackets [ ] , after I stopped using them, the TMP_SubMeshUI stopped being created, and the error stopped.

Why is the TMP_SubMeshUI created? I have no clue, but after some iterations I found this worked.

image