Search Unity

TextMesh Pro UnassignedReferenceException: The variable m_sharedMaterial of TextMeshProUGUI has not been assigned

Discussion in 'UGUI & TextMesh Pro' started by funkyCoty, Jan 22, 2020.

  1. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    TMP from package manager: preview.3 - 2.1.0, and yes I already reimported the essential resources:
    upload_2020-1-22_10-36-54.png


    I get a ton of spam for this error on scene startup and editor startup, it also happens when building the project from the command line.

    Code (CSharp):
    1. UnassignedReferenceException: The variable m_sharedMaterial of TextMeshProUGUI has not been assigned.
    2. You probably need to assign the m_sharedMaterial variable of the TextMeshProUGUI script in the inspector.
    3. UnityEngine.Material.GetFloat (System.String name) (at <7d22f8e71133418c87c7b26ea181f3e3>:0)
    4. TMPro.TMP_SubMeshUI.UpdateMaterial () (at Library/PackageCache/com.unity.textmeshpro@2.1.0-preview.3/Scripts/Runtime/TMP_SubMeshUI.cs:702)
    5. TMPro.TMP_SubMeshUI.SetMaterialDirty () (at Library/PackageCache/com.unity.textmeshpro@2.1.0-preview.3/Scripts/Runtime/TMP_SubMeshUI.cs:610)
    6. UnityEngine.UI.MaskableGraphic.OnValidate () (at C:/Program Files/Unity/Hub/Editor/2019.3.0f3/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/UI/Core/MaskableGraphic.cs:171)
    upload_2020-1-22_10-35-47.png
     
  2. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    To help debug, here's some more info.

    I added in a thing so I could find out which objects were causing this error to spit out, here's an example of one:

    upload_2020-1-22_11-5-8.png

    upload_2020-1-22_11-5-20.png

    (in this case, its the deepest child here that has the error?)
     
  3. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    I am already aware of this issue which has already been resolved. The fix will be included in the next preview release which will be Preview 4 which should be out later this week or over the weekend.

    See the following post for the revised code.
     
  4. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    Thanks, good to hear. I'd like to drop in the code, but anything in the package manager system seems to re-write itself once Unity is re-opened, annoying.
     
  5. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    The change has to be done in the Global Package Cache otherwise it does indeed get reset whenever Unity is closed / reopened.
     
  6. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    Note, I recently updated to preview 4, and reimported the essential assets. I still get this error:

    Code (CSharp):
    1. UnassignedReferenceException: The variable m_sharedMaterial of TextMeshProUGUI has not been assigned.
    2. You probably need to assign the m_sharedMaterial variable of the TextMeshProUGUI script in the inspector.
    3. UnityEngine.Material.GetFloat (System.String name) (at <f38c71c86aa64e299d4cea9fb7c715e1>:0)
    4. TMPro.TMP_SubMeshUI.UpdateMaterial () (at Library/PackageCache/com.unity.textmeshpro@2.1.0-preview.4/Scripts/Runtime/TMP_SubMeshUI.cs:706)
    5. TMPro.TMP_SubMeshUI.SetMaterialDirty () (at Library/PackageCache/com.unity.textmeshpro@2.1.0-preview.4/Scripts/Runtime/TMP_SubMeshUI.cs:614)
    6. UnityEngine.UI.MaskableGraphic.OnValidate () (at C:/Program Files/Unity/Hub/Editor/2019.3.0f6/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/UI/Core/MaskableGraphic.cs:171)
    7.  
     
  7. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Are you able to reproduce the behavior with some simple repro scene? If so, can you provide me with such a scene so I can take a look at this?

    It should be trivial to resolve with some null check but I want to first understand why m_sharedMaterial is null first.
     
  8. WookieWookie

    WookieWookie

    Joined:
    Mar 10, 2014
    Posts:
    35
    @Stephan_B This is still happening for me with the latest package. 2.1.0 preview.8
     
  9. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Can you please submit a bug report which includes the project and scene that would enable me to reproduce the issue?

    If you do submit a bug report please provide me with the Case # once you get the confirmation email reply from Unity.