UnassignedReferenceException: The variable m_sharedMaterial of TextMeshProUGUI has not been assigned

TMP from package manager: preview.3 - 2.1.0, and yes I already reimported the essential resources:
5397861--547719--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.

UnassignedReferenceException: The variable m_sharedMaterial of TextMeshProUGUI has not been assigned.
You probably need to assign the m_sharedMaterial variable of the TextMeshProUGUI script in the inspector.
UnityEngine.Material.GetFloat (System.String name) (at <7d22f8e71133418c87c7b26ea181f3e3>:0)
TMPro.TMP_SubMeshUI.UpdateMaterial () (at Library/PackageCache/com.unity.textmeshpro@2.1.0-preview.3/Scripts/Runtime/TMP_SubMeshUI.cs:702)
TMPro.TMP_SubMeshUI.SetMaterialDirty () (at Library/PackageCache/com.unity.textmeshpro@2.1.0-preview.3/Scripts/Runtime/TMP_SubMeshUI.cs:610)
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)

1 Like

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:

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

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.

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.

The change has to be done in the Global Package Cache otherwise it does indeed get reset whenever Unity is closed / reopened.

Note, I recently updated to preview 4, and reimported the essential assets. I still get this error:

UnassignedReferenceException: The variable m_sharedMaterial of TextMeshProUGUI has not been assigned.
You probably need to assign the m_sharedMaterial variable of the TextMeshProUGUI script in the inspector.
UnityEngine.Material.GetFloat (System.String name) (at <f38c71c86aa64e299d4cea9fb7c715e1>:0)
TMPro.TMP_SubMeshUI.UpdateMaterial () (at Library/PackageCache/com.unity.textmeshpro@2.1.0-preview.4/Scripts/Runtime/TMP_SubMeshUI.cs:706)
TMPro.TMP_SubMeshUI.SetMaterialDirty () (at Library/PackageCache/com.unity.textmeshpro@2.1.0-preview.4/Scripts/Runtime/TMP_SubMeshUI.cs:614)
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)
1 Like

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.

@Stephan_B This is still happening for me with the latest package. 2.1.0 preview.8

1 Like

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.