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

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:

IndexOutOfRangeException: Index was outside the bounds of the array.
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)
TMPro.TMP_InputField.OnFillVBO (UnityEngine.Mesh vbo) (at Library/PackageCache/com.unity.textmeshpro@2.0.0/Scripts/Runtime/TMP_InputField.cs:3276)
TMPro.TMP_InputField.UpdateGeometry () (at Library/PackageCache/com.unity.textmeshpro@2.0.0/Scripts/Runtime/TMP_InputField.cs:3209)
TMPro.TMP_InputField.Rebuild (UnityEngine.UI.CanvasUpdate update) (at Library/PackageCache/com.unity.textmeshpro@2.0.0/Scripts/Runtime/TMP_InputField.cs:3184)
UnityEngine.UI.CanvasUpdateRegistry.PerformUpdate () (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/CanvasUpdateRegistry.cs:198)
UnityEngine.Canvas:SendWillRenderCanvases()

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)

Can you submit a bug report with the project and reproduction steps on this?

Sent. (scratch that, unity bug reporter error-ed out sending, send works without project)

You can always send me a PM with a private link to some repro project if the bug reporter is failing.

1 Like

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

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.

I can also repeat this one. It triggers when you focus TMP_InputField with the input field’s text disabled

Please test with preview 8 and let me know if you are still able to reproduce the issue.

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.

I solved it by going to the text child game object and changing the overflow value from truncate to overflow.

That worked for me, thanks!

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.