Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

TextMesh Pro (2018.2.10f1) IndexOutOfRangeException when using linked text mesh pros.

Discussion in 'UGUI & TextMesh Pro' started by Asusralis, Sep 29, 2018.

  1. Asusralis

    Asusralis

    Joined:
    Oct 27, 2016
    Posts:
    11
    This only happens when I set the overflow to linked and add another textmeshpro as the target.

    IndexOutOfRangeException: Index was outside the bounds of the array.
    TMPro.TextMeshProUGUI.GenerateTextMesh () (at C:/Users/Kyle/AppData/Local/Unity/cache/packages/packages.unity.com/com.unity.textmeshpro@1.2.4/Scripts/Runtime/TMPro_UGUI_Private.cs:2328)
    TMPro.TextMeshProUGUI.OnPreRenderCanvas () (at C:/Users/Kyle/AppData/Local/Unity/cache/packages/packages.unity.com/com.unity.textmeshpro@1.2.4/Scripts/Runtime/TMPro_UGUI_Private.cs:1641)
    TMPro.TextMeshProUGUI.ForceMeshUpdate () (at C:/Users/Kyle/AppData/Local/Unity/cache/packages/packages.unity.com/com.unity.textmeshpro@1.2.4/Scripts/Runtime/TextMeshProUGUI.cs:483)
    TMPro.TextMeshProUGUI.GenerateTextMesh () (at C:/Users/Kyle/AppData/Local/Unity/cache/packages/packages.unity.com/com.unity.textmeshpro@1.2.4/Scripts/Runtime/TMPro_UGUI_Private.cs:2765)
    TMPro.TextMeshProUGUI.OnPreRenderCanvas () (at C:/Users/Kyle/AppData/Local/Unity/cache/packages/packages.unity.com/com.unity.textmeshpro@1.2.4/Scripts/Runtime/TMPro_UGUI_Private.cs:1641)
    TMPro.TextMeshProUGUI.Rebuild (UnityEngine.UI.CanvasUpdate update) (at C:/Users/Kyle/AppData/Local/Unity/cache/packages/packages.unity.com/com.unity.textmeshpro@1.2.4/Scripts/Runtime/TextMeshProUGUI.cs:209)
    UnityEngine.UI.CanvasUpdateRegistry.PerformUpdate () (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/CanvasUpdateRegistry.cs:150)
    UnityEngine.Canvas:SendWillRenderCanvases()
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Does this happen every time or just with a certain block of text?

    Can you provide the steps to reproduce this?

    Does example scene 16 work correctly when you load it?
     
  3. Asusralis

    Asusralis

    Joined:
    Oct 27, 2016
    Posts:
    11
    It only happens when the first text mesh pro component overflows into the linked one.

    Yes, scene 16 works.

    I sadly cannot provide steps because how inconsistent it is. I tried to recreate it in a different scene but it didn't work. The error will go away for a while and then come back.
     
  4. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Didn't work in the sense you were still getting errors or it was behaving correctly in the new scene?
     
  5. Asusralis

    Asusralis

    Joined:
    Oct 27, 2016
    Posts:
    11
    Oh, sorry. I was not getting errors with a new scene. I also remade the objects that the components were on, but the same error appeared.
     
  6. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Just to recap...
    (1) Recreating a similar setup in a new scene does not produce errors.
    (2) Remaking the objects in the same scene produces these errors.

    Comparing both setup, what are the differences?
    - Is the text exactly the same in both cases?
    - How about the size of the RectTransform?
    - Are you using any Layout components in one case but not in the other?

    Are you able to export a simple scene the produces the error and provide it to me?
     
  7. Matt-Cranktrain

    Matt-Cranktrain

    Joined:
    Sep 10, 2013
    Posts:
    129
    Hi @Stephan_B, Bumping this thread because I'm experiencing the exact same issue and error, just with Unity 2019.3.3f1 and Text Mesh Pro 2.0.1.

    It's easy to reproduce. Here's my scene hierarchy:



    My goal is to simply wrap the text around the image. You can see it actually works in Scene view a little bit, but if I select any element, or save the scene, or interact with Unity in any way, the text in the lower 'Overflow' Text Mesh Pro object vanishes, and sometimes the IndexOutOfRangeException previously described in this thread happens. At runtime it's worse yet; the only way to get the text to display is to edit the text, where it displays the text correctly and triggers the error alternatively with every key stroke.

    Odd, inconsistent behaviour aside, it's not hard to reproduce. My layout groups/elements for the above Scene Hierarchy are as follows:
    • The Vertical Layout Container has 'Control Child Size' on for both Width and Height, but I only Child Force Expand on Width.
    • Both 'Row 1' and 'Row 2' have a Horizontal Layout Group. Row 1 has Control Child Size turned on for Width only.
    • Row 2 has Control Child Size turned on for both Width and Height, and Child Force Expand on for Height only.
    • The image has a Layout Element which enforces a Min and Preferred width and height to keep it square.
    • There are no Layout Elements applied to either the Text Mesh Pro objects.
    Pretty straightforward. My guess is that the Layout Manager's height calculation is fighting with Text Mesh mesh calculation.

    If there's an easier way to wrap text around the image (not involving TMPro Sprite Assets, I need to use images here) using Layout Groups, I'm keen to hear it, otherwise a fix for this bug would be great.
     
  8. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Please test using version 2.1.0-preview.8 as I have made improvements to Text Overflow modes including Linked Text.
     
    Matt-Cranktrain likes this.
  9. Matt-Cranktrain

    Matt-Cranktrain

    Joined:
    Sep 10, 2013
    Posts:
    129
    Can confirm this issue is fixed in 2.1.0-preview.8.

    Thanks Stephan!

    Sorry - had a click around and couldn't find any information about Text Mesh Pro's preview packages or the release cycle; what is the expectation of stability for them? Do you recommend or discourage shipping products with them? Obviously in this case it would be great to commit to using preview.8, but I don't know how unstable previews can be.
     
  10. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    I strongly encourage everyone to test these previous as they contain new functionality and fixes.and to report potential issues. Now if throughout your testing everything appears to be working as expected then by all means continue to use this preview.
     
    Matt-Cranktrain likes this.