Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Bug TMP Dynamic Font / Multi Atlas textures error: m_AtlasTexture has not been assigned

Discussion in 'UGUI & TextMesh Pro' started by isalizart, May 8, 2024.

  1. isalizart

    isalizart

    Joined:
    Apr 29, 2019
    Posts:
    1
    We use dynamic TMP font assets with multi atlas textures for Chinese, Japanese, Korean, etc. These are set as fallback fonts for our main latin fonts.

    TMP_MainFontAsset.png

    TMP_FallbackFont_GenerationSettings.png

    When developers in editor switch to a language that uses fallback fonts, after some time TMP throws en exception:
    -----
    UnassignedReferenceException: The variable m_AtlasTexture of TMP_FontAsset has not been assigned.

    You probably need to assign the m_AtlasTexture variable of the TMP_FontAsset script in the inspector.

    UnityEngine.Object.get_name () (at <fc327b7fe2814a8a95c1d82cb6a3071e>:0)

    TMPro.TMP_FontAsset.SetupNewAtlasTexture () (at Library/PackageCache/com.unity.textmeshpro@3.0.6/Scripts/Runtime/TMP_FontAsset.cs:2415)

    TMPro.TMP_FontAsset.TryAddCharacterInternal (System.UInt32 unicode, TMPro.TMP_Character& character) (at Library/PackageCache/com.unity.textmeshpro@3.0.6/Scripts/Runtime/TMP_FontAsset.cs:2118)

    TMPro.TMP_FontAssetUtilities.GetCharacterFromFontAsset_Internal (System.UInt32 unicode, TMPro.TMP_FontAsset sourceFontAsset, System.Boolean includeFallbacks, TMPro.FontStyles fontStyle, TMPro.FontWeight fontWeight, System.Boolean& isAlternativeTypeface) (at Library/PackageCache/com.unity.textmeshpro@3.0.6/Scripts/Runtime/TMP_FontAssetUtilities.cs:159)

    TMPro.TMP_FontAssetUtilities.GetCharacterFromFontAssets (System.UInt32 unicode, TMPro.TMP_FontAsset sourceFontAsset, System.Collections.Generic.List`1[T] fontAssets, System.Boolean includeFallbacks, TMPro.FontStyles fontStyle, TMPro.FontWeight fontWeight, System.Boolean& isAlternativeTypeface) (at Library/PackageCache/com.unity.textmeshpro@3.0.6/Scripts/Runtime/TMP_FontAssetUtilities.cs:241)

    TMPro.TMP_Text.GetTextElement (System.UInt32 unicode, TMPro.TMP_FontAsset fontAsset, TMPro.FontStyles fontStyle, TMPro.FontWeight fontWeight, System.Boolean& isUsingAlternativeTypeface) (at Library/PackageCache/com.unity.textmeshpro@3.0.6/Scripts/Runtime/TMP_Text.cs:6147)

    TMPro.TextMeshProUGUI.SetArraySizes (TMPro.TMP_Text+UnicodeChar[] unicodeChars) (at Library/PackageCache/com.unity.textmeshpro@3.0.6/Scripts/Runtime/TMPro_UGUI_Private.cs:1209)

    TMPro.TMP_Text.ParseInputText () (at Library/PackageCache/com.unity.textmeshpro@3.0.6/Scripts/Runtime/TMP_Text.cs:1902)

    TMPro.TextMeshProUGUI.OnPreRenderCanvas () (at Library/PackageCache/com.unity.textmeshpro@3.0.6/Scripts/Runtime/TMPro_UGUI_Private.cs:1644)

    TMPro.TextMeshProUGUI.Rebuild (UnityEngine.UI.CanvasUpdate update) (at Library/PackageCache/com.unity.textmeshpro@3.0.6/Scripts/Runtime/TextMeshProUGUI.cs:216)

    UnityEngine.UI.CanvasUpdateRegistry.PerformUpdate () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/CanvasUpdateRegistry.cs:215)

    UnityEngine.Canvas:SendWillRenderCanvases()
    ----

    With the inspector in debug mode > In the fallback font asset > In the Atlas Textures Array: In the moment that the exception occurs, there are two entries, and the second is a type mismatch.

    TMP_Error_01.png

    When continuing to play and toggling additional text, there are additional entries added, which are also a type mismatch or none.

    TMP_Error_02.png
    TMP_Error_02.png
    In some cases, when this issue appears, characters of the fallback font are not displayed in the scene.

    The issue doesn't seem to appear in builds.
    We have tried resetting the font assets multiple times and de- and enabled multi atlas textures, which fixes the error for the current editor session, but when Unity has been closed and opened again, or other people check out the branch, the behaviour appears again.

    Maybe unrelated, but after playing the game in a language that uses fallback fonts, and closing the editor, these font assets appear as changed in version control.

    Does anyone know how this error can be fixed or prevented?
     

    Attached Files: