Search Unity

Null Pointer Exception: Material Get Fallback--odd circumstance

Discussion in 'UGUI & TextMesh Pro' started by lagomosker, Jun 25, 2019.

  1. lagomosker

    lagomosker

    Joined:
    Feb 9, 2019
    Posts:
    2
    The full message and then the actual source code (untouched by me except for highlighting the problem line) it directs me to is below: I've deleted and reloaded the package as well. What seems especially odd is the trigger: capital letters, specifically a Shift E when I'm in the editor (2019.1.0f2)
    Thank you,
    David


    NullReferenceException: Object reference not set to an instance of an object
    TMPro.TMP_MaterialManager.GetFallbackMaterial (UnityEngine.Material sourceMaterial, UnityEngine.Material targetMaterial) (at Library/PackageCache/com.unity.textmeshpro@2.0.1/Scripts/Runtime/TMP_MaterialManager.cs:365)
    TMPro.TextMeshProUGUI.SetArraySizes (TMPro.TMP_Text+UnicodeChar[] chars) (at Library/PackageCache/com.unity.textmeshpro@2.0.1/Scripts/Runtime/TMPro_UGUI_Private.cs:1344)
    TMPro.TMP_Text.ParseInputText () (at Library/PackageCache/com.unity.textmeshpro@2.0.1/Scripts/Runtime/TMP_Text.cs:1716)
    TMPro.TextMeshProUGUI.OnPreRenderCanvas () (at Library/PackageCache/com.unity.textmeshpro@2.0.1/Scripts/Runtime/TMPro_UGUI_Private.cs:1637)
    TMPro.TextMeshProUGUI.Rebuild (UnityEngine.UI.CanvasUpdate update) (at Library/PackageCache/com.unity.textmeshpro@2.0.1/Scripts/Runtime/TextMeshProUGUI.cs:209)
    UnityEngine.UI.CanvasUpdateRegistry.PerformUpdate () (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/CanvasUpdateRegistry.cs:198)
    UnityEngine.Canvas:SendWillRenderCanvases()


    public static Material GetFallbackMaterial (Material sourceMaterial, Material targetMaterial)
    {
    int sourceID = sourceMaterial.GetInstanceID();
    Texture tex = targetMaterial.GetTexture(ShaderUtilities.ID_MainTex);
    int texID = tex.GetInstanceID();
    long key = (long)sourceID << 32 | (long)(uint)texID;

    if (m_fallbackMaterials.TryGetValue(key, out FallbackMaterial fallback))
    {
    //Debug.Log("Material [" + fallback.fallbackMaterial.name + "] already exists.");
    return fallback.fallbackMaterial;
    }
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Can you please submit a bug report with project and steps to enable me to reproduce this? This might be asset specific or something.

    Let me know if you do submit a bug report and please provide the Case #.
     
  3. lagomosker

    lagomosker

    Joined:
    Feb 9, 2019
    Posts:
    2

    Thanks Stephan. Of course, starting with a clean project, there are no problems. I can replicate it an existing project in a blank scene:
    Create a canvas,
    Add a TextMeshPro Text object
    Change the font asset to Liberation Front SDF Fallback because the non-fallback version just gives me blocks. (That might be a clue).
    Start typing. Shift E throws it all out of whack.

    Could removing/re-installing adding in the package manager not be doing a total cleanse and there corrupted artifacts somewhere?
     
  4. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    In the event the TMP Essential Resources got corrupted in some fashion, you can simply re-import the TMP Essential Resources by going to the Window - TextMeshPro - Import TMP Essential Resources. This will bring up a window of everything that will be imported and allow you to see which assets were actually modified / different. If this issue is due to some of these changes, this should fix it.