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.
TMPro.TextMeshProUGUI.GenerateTextMesh () (at Library/PackageCache/com.unity.textmeshpro@1.4.1/Scripts/Runtime/TMPro_UGUI_Private.cs:2098)
TMPro.TextMeshProUGUI.OnPreRenderCanvas () (at Library/PackageCache/com.unity.textmeshpro@1.4.1/Scripts/Runtime/TMPro_UGUI_Private.cs:1657)
TMPro.TextMeshProUGUI.Rebuild (UnityEngine.UI.CanvasUpdate update) (at Library/PackageCache/com.unity.textmeshpro@1.4.1/Scripts/Runtime/TextMeshProUGUI.cs:209)
UnityEngine.UI.CanvasUpdateRegistry.PerformUpdate () (at /Users/builduser/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/CanvasUpdateRegistry.cs:198)
UnityEngine.UI.ScrollRect:LateUpdate()
Hi, I am using Unity2018.4.4
I have a (Text (TMP) game object) with this text written below
• Allows after market stereo to be installed in factory location
The above text creates a child with TMP SubMeshUI [LiberationSans SDF Material] component. Which throughs the error “‘Material’ has been destroyed”.
The same issue on Unity 2019.4.10f1 with TextMeshPro 2.1.3
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 <ee47be73f7ef409ca5e5ce4b121745b7>:0)
TMPro.TMP_SubMeshUI.AddSubTextObject (TMPro.TextMeshProUGUI textComponent, TMPro.MaterialReference materialReference) (at Library/PackageCache/com.unity.textmeshpro@2.1.3/Scripts/Runtime/TMP_SubMeshUI.cs:214)
TMPro.TextMeshProUGUI.SetArraySizes (TMPro.TMP_Text+UnicodeChar[] unicodeChars) (at Library/PackageCache/com.unity.textmeshpro@2.1.3/Scripts/Runtime/TMPro_UGUI_Private.cs:1383)
TMPro.TMP_Text.ParseInputText () (at Library/PackageCache/com.unity.textmeshpro@2.1.3/Scripts/Runtime/TMP_Text.cs:1892)
TMPro.TextMeshProUGUI.OnPreRenderCanvas () (at Library/PackageCache/com.unity.textmeshpro@2.1.3/Scripts/Runtime/TMPro_UGUI_Private.cs:1622)
TMPro.TextMeshProUGUI.Rebuild (UnityEngine.UI.CanvasUpdate update) (at Library/PackageCache/com.unity.textmeshpro@2.1.3/Scripts/Runtime/TextMeshProUGUI.cs:224)
UnityEngine.UI.CanvasUpdateRegistry.PerformUpdate () (at C:/Program Files/Unity/Hub/Editor/2019.4.10f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/UI/Core/CanvasUpdateRegistry.cs:210)
UnityEngine.UI.ScrollRect:LateUpdate() (at C:/Program Files/Unity/Hub/Editor/2019.4.10f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/UI/Core/ScrollRect.cs:805)
I’m defining a prefab (variant) with TMP text on it, which auto-generates TMP SubMeshUI [LiberationSans SDF Material] child (although I’m using a different font), and the prefab instance sometimes creates its own child too, sometimes has no children at all (not sure how it’s possible, it manages to bypass “prefab permissions” and delete/replace a prefab child?).
Happens for me as well on 2021.3.6f1 LTS and TMP 3.0.6.
It happens only with a “Bitmap Custom Atlas” shader that a submesh is created and it gets deleted after exiting play mode. If I deactivate the TextMeshPro object then in the editor and reactivate it, the submesh gets created anew.
Same issue. I also have Bitmap custom atlas. Not all ascii characters are mapped in the bitmap and I am changing text via code. Using 2021.3.18f1 LTS and TMP 3.0.6
Resetting the editor isn’t going to solve this issue because the vast majority of people who are reporting this error (like myself) see it constantly. I see it every time I exit play mode. I tried Datablob’s suggestion of (Resetting the Default Font Asset) and it seems to have solved it for now.
Getting the same issue and the aforementioned fixes do not help. This happens when using prefabs and prefabs variants that have a TMP child with a custom font. Breaks builds unless we set the standard font
I was using a bitmap font and noticed that the submesh object was being created due to spaces in the string. I’m assuming the spaces are rendered by the fallback font.
Apparently my bitmap font is lacking a space character? This only happens with the raster hinted version of the font asset, SDF is curiously unaffected, neither show a char/glyph for space when I search for them in the font asset inspector.
Anyone had any luck with this? Literally doing my head in.
It lets me set my fonts to LiberationSans SDF, but using my custom fonts results in the ‘The object of type ‘Material’ has been destroyed but you are still trying to access it’ errors which occur at line 1403 of the TMPro_UGUI_Private.cs > line 215 of the TMP_SubMeshUI.cs.
These errors only occur after closing the game from the game viewer.
I am also able to actually see my fonts displayed just fine.
I might add that this started happening when upgrading from 2019 to 2021.3.30f1 version of unity, I didn’t get these errors in the 2019 version I was using.
I can also actually use all my custom fonts just fine, I just want to prevent the error spam after running in the Game Viewer.