Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

TextMesh Pro Getting error message MissingReferenceException: The object of type 'Material' has been destroyed

Discussion in 'UGUI & TextMesh Pro' started by sushanta1991, Dec 26, 2019.

  1. sushanta1991

    sushanta1991

    Joined:
    Apr 3, 2011
    Posts:
    304
    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 error comes after I close the play mode.
     
  2. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,581
    Please test with the latest preview release of TMP which is version 1.5.0-preview.3 and let me know if the issue persists.
     
  3. Tymianek

    Tymianek

    Joined:
    May 16, 2015
    Posts:
    91
    The same issue on Unity 2019.4.10f1 with TextMeshPro 2.1.3

    Code (CSharp):
    1. MissingReferenceException: The object of type 'Material' has been destroyed but you are still trying to access it.
    2. Your script should either check if it is null or you should not destroy the object.
    3. UnityEngine.Object.get_name () (at <ee47be73f7ef409ca5e5ce4b121745b7>:0)
    4. 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)
    5. TMPro.TextMeshProUGUI.SetArraySizes (TMPro.TMP_Text+UnicodeChar[] unicodeChars) (at Library/PackageCache/com.unity.textmeshpro@2.1.3/Scripts/Runtime/TMPro_UGUI_Private.cs:1383)
    6. TMPro.TMP_Text.ParseInputText () (at Library/PackageCache/com.unity.textmeshpro@2.1.3/Scripts/Runtime/TMP_Text.cs:1892)
    7. TMPro.TextMeshProUGUI.OnPreRenderCanvas () (at Library/PackageCache/com.unity.textmeshpro@2.1.3/Scripts/Runtime/TMPro_UGUI_Private.cs:1622)
    8. TMPro.TextMeshProUGUI.Rebuild (UnityEngine.UI.CanvasUpdate update) (at Library/PackageCache/com.unity.textmeshpro@2.1.3/Scripts/Runtime/TextMeshProUGUI.cs:224)
    9. 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)
    10. 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)
     
  4. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,581
    Can you submit a bug report with project and steps for me to take a closer look at?

    If you do submit a bug report please provide me with the Case # once you get it from Unity via email.
     
  5. Tymianek

    Tymianek

    Joined:
    May 16, 2015
    Posts:
    91
    After reimporting the project I couldn't reproduce the bug :D
     
    navywill likes this.
  6. soulsinister

    soulsinister

    Joined:
    Aug 12, 2022
    Posts:
    1
    im having the same problem
     
  7. af_unity994

    af_unity994

    Joined:
    Aug 17, 2022
    Posts:
    1
    Any solutions? I'm having the issue on Unity version 2021.3.8f1
     
  8. GilJoWal

    GilJoWal

    Joined:
    Mar 28, 2020
    Posts:
    22
    Happening with 2021.3.10 as well
     
  9. huulong

    huulong

    Joined:
    Jul 1, 2013
    Posts:
    206
    Got it on 2022.1.10f1 with TMP 3.0.6.

    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?).
     
  10. Olipool

    Olipool

    Joined:
    Feb 8, 2015
    Posts:
    200
    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.