Search Unity

TextMesh Pro IndexOutOfRangeException when trying to display text

Discussion in 'UGUI & TextMesh Pro' started by unity_gVZpQxeE0d2rPw, Apr 24, 2018.

  1. unity_gVZpQxeE0d2rPw

    unity_gVZpQxeE0d2rPw

    Joined:
    Apr 9, 2018
    Posts:
    1
    I change the text property of a TextMeshProUGUI in a script and when that text should get displayed I get a "IndexOutOfRangeException: Index was outside the bounds of the array." error message and the display field is blank. I can see the text within the inspector in the editor and if I change it there it starts getting displayed in the game as well.

    [Exception] IndexOutOfRangeException: Index was outside the bounds of the array.
    TMP_Text.FillCharacterVertexBuffers() C:/ProgramData/Unity/cache/packages/packages.unity.com/com.unity.textmeshpro@1.2.2/Scripts/Runtime/TMP_Text.cs:4957
    4956: // Setup Vertices for Characters
    -->4957: m_textInfo.meshInfo[materialIndex].vertices[0 + index_X4] = characterInfoArray.vertex_BL.position;
    4958: m_textInfo.meshInfo[materialIndex].vertices[1 + index_X4] = characterInfoArray.vertex_TL.position;
    4959: m_textInfo.meshInfo[materialIndex].vertices[2 + index_X4] = characterInfoArray.vertex_TR.position;

    TextMeshProUGUI.GenerateTextMesh() C:/ProgramData/Unity/cache/packages/packages.unity.com/com.unity.textmeshpro@1.2.2/Scripts/Runtime/TMPro_UGUI_Private.cs:3573
    3571: if (elementType == TMP_TextElementType.Character)
    3572: {
    -->3573: FillCharacterVertexBuffers(i, vert_index_X4);
    3574: }
    3575: else if (elementType == TMP_TextElementType.Sprite)

    TextMeshProUGUI.GenerateTextMesh() C:/ProgramData/Unity/cache/packages/packages.unity.com/com.unity.textmeshpro@1.2.2/Scripts/Runtime/TMPro_UGUI_Private.cs:2685
    2683: m_totalCharacterCount = ellipsisIndex + 1;
    -->2685: GenerateTextMesh();
    2686: m_isTextTruncated = true;
    2687: return;

    TextMeshProUGUI.GenerateTextMesh() C:/ProgramData/Unity/cache/packages/packages.unity.com/com.unity.textmeshpro@1.2.2/Scripts/Runtime/TMPro_UGUI_Private.cs:2685
    2683: m_totalCharacterCount = ellipsisIndex + 1;
    -->2685: GenerateTextMesh();
    2686: m_isTextTruncated = true;
    2687: return;

    TextMeshProUGUI.OnPreRenderCanvas() C:/ProgramData/Unity/cache/packages/packages.unity.com/com.unity.textmeshpro@1.2.2/Scripts/Runtime/TMPro_UGUI_Private.cs:1641
    1639: m_ignoreActiveState = false;
    -->1641: GenerateTextMesh();
    1642: }
    1643: }

    TextMeshProUGUI.Rebuild() C:/ProgramData/Unity/cache/packages/packages.unity.com/com.unity.textmeshpro@1.2.2/Scripts/Runtime/TextMeshProUGUI.cs:209
    207: else if (update == CanvasUpdate.PreRender)
    208: {
    -->209: OnPreRenderCanvas();
    211: m_verticesAlreadyDirty = false;

    CanvasUpdateRegistry.PerformUpdate() C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/CanvasUpdateRegistry.cs:150

    Canvas.SendWillRenderCanvases()

     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Since many things could be contributing to this behavior like the raw text, container size, layout components, the fact that the text is truncated and using Ellipsis, etc.I will need more information and most likely a Repro project.

    If you are able to reproduce reliably, could you please submit a bug report and provide me with the Case# or simply post a Repro Project here?