Search Unity

TextMesh Pro NullReferenceException in TextMeshProUGUI

Discussion in 'UGUI & TextMesh Pro' started by Deleted User, Aug 28, 2019.

  1. Deleted User

    Deleted User

    Guest

    I'm trying to use a custom font with TMP. TextMeshPro version is 2.0.1.
    Here is the error:

    NullReferenceException: Object reference not set to an instance of an object
    TMPro.TextMeshProUGUI.GenerateTextMesh () (at Packages/com.unity.textmeshpro@2.0.1/Scripts/Runtime/TMPro_UGUI_Private.cs:2025)
    TMPro.TextMeshProUGUI.OnPreRenderCanvas () (at Packages/com.unity.textmeshpro@2.0.1/Scripts/Runtime/TMPro_UGUI_Private.cs:1656)
    TMPro.TextMeshProUGUI.Rebuild (UnityEngine.UI.CanvasUpdate update) (at Packages/com.unity.textmeshpro@2.0.1/Scripts/Runtime/TextMeshProUGUI.cs:209)
    UnityEngine.UI.CanvasUpdateRegistry.PerformUpdate () (at C:/Program Files/Unity/2019.2.0f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/UI/Core/CanvasUpdateRegistry.cs:198)
    UnityEngine.Canvas:SendWillRenderCanvases()

    What is the problem?
     
  2. Deleted User

    Deleted User

    Guest

    If I specify the Liberation Sans font as fallback, the error goes away.
     
  3. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Is this a new font asset that you are creating?

    Are you creating it using the Font Asset Creator or selecting the font file and using the Context Menu Create - TextMeshPro - Font Asset?
     
  4. Deleted User

    Deleted User

    Guest

    I'm creating a new font asset using Font Asset Creator window.

    Since the font is likely not standard (This is one of those free fonts on the web), I guess there's something missing in the font file that causes TMP to throw errors. Is there anything that I can check for?

    I'm using Unicode Range to generate font asset. Can a missing character in those Unicode Ranges lead to this error?
     
  5. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Most likely, there is some issue with the font file. Can you provide me with a link to this font?