Search Unity

TextMeshPro 1.4.0 : ArgumentOutOfRangeException when using emotes sprites assets

Discussion in 'UGUI & TextMesh Pro' started by BBO_Lagoon, Mar 29, 2019.

  1. BBO_Lagoon

    BBO_Lagoon

    Joined:
    Mar 2, 2017
    Posts:
    200
    Hi, I have an error on some texts with emotes sprites assets.
    Here is the error stack trace:

    ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index
    System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) (at <d7ac571ca2d04b2f981d0d886fa067cf>:0)
    System.ThrowHelper.ThrowArgumentOutOfRangeException () (at <d7ac571ca2d04b2f981d0d886fa067cf>:0)
    System.Collections.Generic.List`1[T].get_Item (System.Int32 index) (at <d7ac571ca2d04b2f981d0d886fa067cf>:0)
    TMPro.TextMeshPro.SetArraySizes (TMPro.TMP_Text+UnicodeChar[] chars) (at Library/PackageCache/com.unity.textmeshpro@1.4.0-preview.3a/Scripts/Runtime/TMPro_Private.cs:1125)
    TMPro.TMP_Text.ParseInputText () (at Library/PackageCache/com.unity.textmeshpro@1.4.0-preview.3a/Scripts/Runtime/TMP_Text.cs:1725)
    TMPro.TextMeshPro_OnPreRenderObject () (at Library/PackageCache/com.unity.textmeshpro@1.4.0-preview.3a/Scripts/Runtime/TMPro_Private.cs:1530)
    TMPro.TextMeshPro.Rebuild (UnityEngine.UI.CanvasUpdate update) (at Library/PackageCache/com.unity.textmeshpro@1.4.0-preview.3a/Scripts/Runtime/TextMeshPro.cs:241)
    TMPro.TMP_UpdateManager.DoRebuilds () (at Library/PackageCache/com.unity.textmeshpro@1.4.0-preview.3a/Scripts/Runtime/TMP_UpdateManager.cs:187)
    TMPro.TMP_UpdateManager.OnCameraPreCull (UnityEngine.Camera cam) (at Library/PackageCache/com.unity.textmeshpro@1.4.0-preview.3a/Scripts/Runtime/TMP_UpdateManager.cs:158)
    UnityEngine.Camera.FireOnPreCull (UnityEngine.Camera cam) (at C:/buildslave/unity/build/Runtime/Export/Camera.bindings.cs:334)
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    I'll need more details on how to reproduce these errors.

    Can you provide a simple repro project or scene for me to look at?
     
  3. BBO_Lagoon

    BBO_Lagoon

    Joined:
    Mar 2, 2017
    Posts:
    200
    OK here is the link for the repro project on google drive: https://drive.google.com/file/d/1gRXMyZShKQG88IPexQJN3dNkEoeUKZSD/view?usp=sharing

    As you can see I have some dynamic fallback font assets in my project (maybe this is what is casing the issue).

    I added a script on the Main Camera with 3 buttons: SetText1, SetText2 and ClearTexts.
    To reproduce the bug, just launch the scene (Play) then hit SetText2, ClearTexts, SetText2 and then you will see the error.
    Only the second text is causing problems, If you try with SetText1 no error occurs.
     
  4. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Thanks for providing the repro project. I'll take a look tomorrow when I wake up.
     
  5. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Make the following changes in the TMPro_Private.cs at line 1125 and 1181 as well as in TMPro_UGUI_Private.cs at line 1195 and 1251.

    Code (csharp):
    1.  
    2. // Replace m_spriteIndex by spriteIndex
    3. m_textInfo.characterInfo[m_totalCharacterCount].textElement = spriteAsset.spriteCharacterTable[spriteIndex];
    Not sure how I missed this in the first place. Thank you for having taken the time to report the issue and to provide the repro case which made identifying this simple.
     
    the_othernet likes this.
  6. BBO_Lagoon

    BBO_Lagoon

    Joined:
    Mar 2, 2017
    Posts:
    200
    Thanks to you to correct it so fast :)
     
    Stephan_B likes this.
  7. the_othernet

    the_othernet

    Joined:
    May 25, 2016
    Posts:
    7
    This is still showing up in 2.01, but the fix mentioned above thankfully works well.

    [Edit]
    Unfortunately it looks like this patch is automatically reset at times and I have to update it again before building for the store.
     
    Last edited: Sep 25, 2019
  8. igor_rst

    igor_rst

    Joined:
    Apr 20, 2017
    Posts:
    40
    Yeah, I have a same error (2.0.1). When it will be fixed?
     
  9. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Can you test with the latest release which is version 2.1.0-preview.1?
     
  10. igor_rst

    igor_rst

    Joined:
    Apr 20, 2017
    Posts:
    40
    Seems it works with preview version.. Will do more tests.
    BTW, when will be emoji support with modificators? Like flags, skin color, etc
     
  11. the_othernet

    the_othernet

    Joined:
    May 25, 2016
    Posts:
    7
    Yes, the preview version fixes it. Thank you.