Search Unity

Bug Issue with m_sharedMaterial after importing package from 2020 project.

Discussion in 'UGUI & TextMesh Pro' started by Gohloum, Dec 14, 2022.

  1. Gohloum

    Gohloum

    Joined:
    Nov 29, 2018
    Posts:
    12
    Hello,

    I am getting the following error in my console after importing a UI that was from an older project which was started in 2019.x, then upgraded to 2020.x. I simply exported the UI as an asset and imported it into the new project. My current project is 2022.1.17f1 and TextMeshPro 3.0.6 is what I have installed via the PackageManager.

    Error: MissingReferenceException: The variable m_sharedMaterial of TextMeshProUGUI doesn't exist anymore.
    You probably need to reassign the m_sharedMaterial variable of the 'TextMeshProUGUI' script in the inspector.

    Originally I had about 40+ of these and as I went through the UI I was able to find the troubling TextMeshPro text fields that were appending the TMP_SubMeshUI object. I replaced all of them and that seemed to have solved the problem except for just 4 errors now. I have thoroughly gone through my UI objects and validated that all the TextMeshPro text objects have been replaced, however, I am still seeing the error 4 times in my console on re-compile.

    I am open to suggestions on how to go about fixing this. It's not causing my project to crash, but it is annoying and I would like to reconcile the issue. Any suggestions on how I could trace down the offending code or objects? Due to an NDA, I can't post a sample project, so I'm on my own to resolve it. Any suggestions would be greatly appreciated. The most detail I have in the console per error is the following:

    MissingReferenceException: The variable m_sharedMaterial of TextMeshProUGUI doesn't exist anymore.
    You probably need to reassign the m_sharedMaterial variable of the 'TextMeshProUGUI' script in the inspector.
    UnityEngine.Material.GetFloat (System.String name) (at <790a43858b4b404fbe02a2b7b4a0d9d6>:0)
    TMPro.TMP_SubMeshUI.UpdateMaterial () (at Library/PackageCache/com.unity.textmeshpro@3.0.6/Scripts/Runtime/TMP_SubMeshUI.cs:710)
    TMPro.TMP_SubMeshUI.SetMaterialDirty () (at Library/PackageCache/com.unity.textmeshpro@3.0.6/Scripts/Runtime/TMP_SubMeshUI.cs:617)
    UnityEngine.UI.MaskableGraphic.OnValidate () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/MaskableGraphic.cs:202)

    Thanks!
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    What version of the TMP package were you using before?

    If you were using version 2.2.0-preview.3, then make sure you are using version 3.2.0-pre.3 with Unity 2020.3 or newer.

    Since these errors appear to be related to the sub mesh objects, you can safely delete those sub mesh objects as they are managed by the text component and will be re-created by it as needed. If these are part of Prefabs, remove them from the prefabs. These sub mesh objects used to be serialized but that it no longer the case and could cause those types of issues if still part of prefabs.

    Let me know if the above helps otherwise, it might be easier if you could provide me with some repro / exported scene to enable me to take a closer look. You can provide this via Private Message if needed or submit a bug report with project and them provide me with the case # / link to bug report.
     
  3. Gohloum

    Gohloum

    Joined:
    Nov 29, 2018
    Posts:
    12
    It would seem that I had a font that was causing the problem with some special characters. Also doing embedded rich text with markup would also cause the issue, however this was interesting because I only saw the objects get attached if I put the markup in the textbox in the Editor's GUI. If I dynamically set the value with markup, there is no issue. Seem the division symbol (Not / but the line with 2 dots) is a problem for several different fonts. I see it render just fine, but those Sub objects get added. I'll try and get you more specifics on it as I observe them.