Search Unity

TextMesh Pro UI TextMeshPro Creating Error: "MissingReferenceException"

Discussion in 'UGUI & TextMesh Pro' started by schuylerzheng, Apr 22, 2023.

  1. schuylerzheng

    schuylerzheng

    Joined:
    Jan 9, 2022
    Posts:
    7
    I am working on some settings for a game, and I add a TextMeshPro from the UI menu. But get the error "
    MissingReferenceException: The object of type 'MeshRenderer' 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.Renderer.get_sharedMaterial () (at <f712b1dc50b4468388b9c5f95d0d0eaf>:0)
    TMPro.TextMeshProN_MATERIAL_PROPERTY_CHANGED (System.Boolean isChanged, UnityEngine.Material mat) (at Library/PackageCache/com.unity.textmeshpro@3.0.6/Scripts/Runtime/TMPro_Private.cs:346)
    TMPro.FastAction`2[A,B].Call (A a, B b) (at Library/PackageCache/com.unity.textmeshpro@3.0.6/Scripts/Runtime/FastAction.cs:109)
    TMPro.TMPro_EventManager.ON_MATERIAL_PROPERTY_CHANGED (System.Boolean isChanged, UnityEngine.Material mat) (at Library/PackageCache/com.unity.textmeshpro@3.0.6/Scripts/Runtime/TMPro_EventManager.cs:41)
    TMPro.EditorUtilities.TMP_BaseShaderGUI.OnGUI (UnityEditor.MaterialEditor materialEditor, UnityEditor.MaterialProperty[] properties) (at Library/PackageCache/com.unity.textmeshpro@3.0.6/Scripts/Editor/TMP_BaseShaderGUI.cs:166)
    UnityEditor.MaterialEditor.PropertiesGUI () (at <9959c9185b684a4d9d56448296fb9048>:0)
    UnityEditor.MaterialEditor.OnInspectorGUI () (at <9959c9185b684a4d9d56448296fb9048>:0)
    UnityEditor.UIElements.InspectorElement+<>c__DisplayClass59_0.<CreateIMGUIInspectorFromEditor>b__0 () (at <510ab1fb30824c58abfe98a586cf7b5f>:0)
    UnityEngine.GUIUtilityProcessEvent(Int32, IntPtr, Boolean&)" I know the problem comes from the mesh renderer, but I don't know how to fix it. Screenshot 2023-04-21 212914.png
     
  2. KimmoFactor

    KimmoFactor

    Joined:
    Dec 29, 2020
    Posts:
    39
    I suspect it's a bug. I started getting the same thing now. Hadn't really touched this part of my game in a long time, the last time was in 2021 Unity and it worked fine. But now I'm at 2022.2.16 and started working on it again, it started doing this after a few runs (nothing's really changed). (My TMP package is 3.0.6)

    Code (csharp):
    1.  
    2. MissingReferenceException: The object of type 'MeshRenderer' has been destroyed but you are still trying to access it.
    3. Your script should either check if it is null or you should not destroy the object.
    4. UnityEngine.Renderer.get_sharedMaterial () (at <b0fc6facff52490f8c5788181f70c5cc>:0)
    5. TMPro.TextMeshPro.ON_MATERIAL_PROPERTY_CHANGED (System.Boolean isChanged, UnityEngine.Material mat) (at ./Library/PackageCache/com.unity.textmeshpro@3.0.6/Scripts/Runtime/TMPro_Private.cs:346)
    6. TMPro.FastAction`2[A,B].Call (A a, B b) (at ./Library/PackageCache/com.unity.textmeshpro@3.0.6/Scripts/Runtime/FastAction.cs:109)
    7. TMPro.TMPro_EventManager.ON_MATERIAL_PROPERTY_CHANGED (System.Boolean isChanged, UnityEngine.Material mat) (at ./Library/PackageCache/com.unity.textmeshpro@3.0.6/Scripts/Runtime/TMPro_EventManager.cs:41)
    8. TMPro.EditorUtilities.TMP_BaseShaderGUI.PrepareGUI () (at ./Library/PackageCache/com.unity.textmeshpro@3.0.6/Scripts/Editor/TMP_BaseShaderGUI.cs:144)
    9. TMPro.EditorUtilities.TMP_BaseShaderGUI.OnGUI (UnityEditor.MaterialEditor materialEditor, UnityEditor.MaterialProperty[] properties) (at ./Library/PackageCache/com.unity.textmeshpro@3.0.6/Scripts/Editor/TMP_BaseShaderGUI.cs:158)
    10. UnityEditor.MaterialEditor.PropertiesGUI () (at <fd50159aad624335967647b443372e50>:0)
    11. UnityEditor.MaterialEditor.OnInspectorGUI () (at <fd50159aad624335967647b443372e50>:0)
    12. UnityEditor.UIElements.InspectorElement+<>c__DisplayClass72_0.<CreateInspectorElementUsingIMGUI>b__0 () (at <fd50159aad624335967647b443372e50>:0)
    13. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
    14.  
     
  3. Ulnari

    Ulnari

    Joined:
    Feb 9, 2014
    Posts:
    15
    Occurred after I added the TMP Text component to an UI element (instead of Text UI), and then removed it. Restarting Unity got rid of it.