Search Unity

TextMesh Pro: InputField.GenerateHighlight throws index out of range exception

Discussion in 'UGUI & TextMesh Pro' started by jason_unity266, May 8, 2019.

  1. jason_unity266

    jason_unity266

    Joined:
    Apr 4, 2019
    Posts:
    3
    I just upgraded from 2018.3.13f1 (textmesh pro 1.3.0) to 2019.1.1f1 (text mesh pro 2.0.0) and am now getting the following error on a TMP_InputField when running:

    Code (CSharp):
    1. IndexOutOfRangeException: Index was outside the bounds of the array.
    2. TMPro.TMP_InputField.GenerateHightlight (UnityEngine.UI.VertexHelper vbo, UnityEngine.Vector2 roundingOffset) (at Library/PackageCache/com.unity.textmeshpro@2.0.0/Scripts/Runtime/TMP_InputField.cs:3395)
    3. TMPro.TMP_InputField.OnFillVBO (UnityEngine.Mesh vbo) (at Library/PackageCache/com.unity.textmeshpro@2.0.0/Scripts/Runtime/TMP_InputField.cs:3276)
    4. TMPro.TMP_InputField.UpdateGeometry () (at Library/PackageCache/com.unity.textmeshpro@2.0.0/Scripts/Runtime/TMP_InputField.cs:3209)
    5. TMPro.TMP_InputField.Rebuild (UnityEngine.UI.CanvasUpdate update) (at Library/PackageCache/com.unity.textmeshpro@2.0.0/Scripts/Runtime/TMP_InputField.cs:3184)
    6. UnityEngine.UI.CanvasUpdateRegistry.PerformUpdate () (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/CanvasUpdateRegistry.cs:198)
    7. UnityEngine.Canvas:SendWillRenderCanvases()
    8.  
    This occurs when I have one input field and then instantiate a prefab with another Input field and copy the text from the first to the second.

    It occurs when you first click on the new input field.

    the caretSelectPositionInternal is -1 which is what causes the argument exception. The strange thing is if I step through the value returned that should be set in caretSelectPositionInternal is 0, but doesn't appear to match (via ClampCaretPos)

    Workaround: downgrading to textmeshpro 1.3.0 fixes the issue. (still an issue in 2.0.1 preview)
     
    Last edited: May 8, 2019
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    Can you submit a bug report with the project and reproduction steps on this?
     
  3. jason_unity266

    jason_unity266

    Joined:
    Apr 4, 2019
    Posts:
    3
    Sent. (scratch that, unity bug reporter error-ed out sending, send works without project)
     
  4. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    You can always send me a PM with a private link to some repro project if the bug reporter is failing.
     
    jason_unity266 likes this.
  5. VRRehabInc

    VRRehabInc

    Joined:
    Nov 3, 2016
    Posts:
    5
    We're also getting this on 2018.4.12f1. Unfortunately I can't send the project (NDA & gov work). Was this ever resolved?
    nevermind, seems to have stopped on its own
     
    Last edited: Nov 22, 2019
  6. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    Make sure you test with the latest release of TMP which is version 1.5.0-preview.2. There are a few known issues with preview.2 related to shaders. Those will be fixed in preview 3 which should be out over the weekend.
     
  7. pmerilainen

    pmerilainen

    Joined:
    Dec 23, 2013
    Posts:
    7
    I can also repeat this one. It triggers when you focus TMP_InputField with the input field's text disabled
     
  8. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    Please test with preview 8 and let me know if you are still able to reproduce the issue.
     
  9. reviyee

    reviyee

    Joined:
    Apr 4, 2018
    Posts:
    18
    This happened to me on 2019.2.17f1. Disabled a TextMeshProUGUI component to see the placeholder text color. Tried running the build and got an index out of range error on GenerateCaret. Fixed by enabling back the component.
     
  10. LoneXUnity

    LoneXUnity

    Joined:
    Mar 24, 2020
    Posts:
    7
    I solved it by going to the text child game object and changing the overflow value from truncate to overflow.
     
  11. AlexTudo_Applio

    AlexTudo_Applio

    Joined:
    Jun 15, 2015
    Posts:
    2
    That worked for me, thanks!
     
  12. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    Please be sure to use the latest release which is version 3.2.0-pre.3 for Unity 2020.3 or newer as I have made several fixes in the Input Field.