Search Unity

Bug GetFloat and AddSubTextObject rrrors when usign TextMeshPro

Discussion in 'UGUI & TextMesh Pro' started by Dasp, Aug 18, 2022.

  1. Dasp

    Dasp

    Joined:
    Sep 25, 2012
    Posts:
    38
    We have issue in our project with TextMeshPro in combination with Addressables. We moved all fonts and materials to addressables and removed them from resource folder. Since then we started getting errors when using Material tag in our texts. Visually text doesn't appear at all until user restarts the game.
    Error stack for GetFloat error. It doesn't happen all the time, only sometimes and besides that everything works well.

    Code (CSharp):
    1. Non-fatal Exception: NullReferenceException
    2. 0  ???                            0x0 get_name + 194 (UnityEngineObject.bindings.cs:194)
    3. 1  ???                            0x0 AddSubTextObject + 215 (TMP_SubMeshUI.cs:215)
    4. 2  ???                            0x0 SetArraySizes + 1467 (TMPro_UGUI_Private.cs:1467)
    5. 3  ???                            0x0 ParseInputText + 1965 (TMP_Text.cs:1965)
    6. 4  ???                            0x0 OnPreRenderCanvas + 1711 (TMPro_UGUI_Private.cs:1711)
    7. 5  ???                            0x0 Rebuild + 216 (TextMeshProUGUI.cs:216)
    8. 6  ???                            0x0 PerformUpdate + 215 (CanvasUpdateRegistry.cs:215)
    9. 7  ???                            0x0 SendWillRenderCanvases + 102 (UICanvas.bindings.cs:102)
    10. 8  ???                            0x0 ForceUpdateCanvases + 90 (UICanvas.bindings.cs:90)
    11. 9  ???                            0x0 EnsureLayoutHasRebuilt + 636 (ScrollRect.cs:636)
    12. 10 ???                            0x0 LateUpdate + 834 (ScrollRect.cs:834)
    13. 11 ???                            0x0 LateUpdate + 279 (ScrollRectExtended.cs:279)
    14. 12 ???                            0x0 ScrollRect:LateUpdate (UnityEngine.UI)
    We are using newest TextMeshPro + Unity 2022.1.13

    This is how we load materials when game starts
    Code (CSharp):
    1. var fontMaterials = Addressables.LoadAssetsAsync<Material>("FontMaterial", null);
    2.         asyncOperationHandles.Add(fontMaterials);
    3.  
    4.         fontMaterials.Completed += fonts =>
    5.         {
    6.             logger.Log($"[Materials] Found {fonts.Result.Count} materials");
    7.             foreach (var material in fonts.Result)
    8.             {
    9.                 int materialHashCode = TMP_TextUtilities.GetHashCode(material.name);
    10.  
    11.                 if(!MaterialReferenceManager.TryGetMaterial(materialHashCode, out Material tempMaterial))
    12.                 {
    13.                     MaterialReferenceManager.AddFontMaterial(materialHashCode, material);
    14.                     logger.Log($"[Materials] Added {material.name} material");
    15.                 }
    16.             }
    17.         };
    Any help solving this issue?
     
  2. Dasp

    Dasp

    Joined:
    Sep 25, 2012
    Posts:
    38
  3. Dasp

    Dasp

    Joined:
    Sep 25, 2012
    Posts:
    38
    Bump
     
  4. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Any chance you could submit a bug report with project or scene that would enable me to reproduce / take a closer look?

    You could also provide me with an exported scene via PM if that is easier.
     
  5. Dasp

    Dasp

    Joined:
    Sep 25, 2012
    Posts:
    38
    Of course, let me create a scene. I will send it in private message
     
    Last edited: Aug 25, 2022