Hello,
Using latest unity version 2021.2.0f1 (UI Toolkit, runtime). I have an input field that is hidden by default, i.e. style.display = DisplayStyle.None.
Using following code will throw IndexOutOfRangeException. It was working in preview packages. Did I miss something or it’s a regression bug?:
_input.style.display = DisplayStyle.Flex;
_input.Focus();
IndexOutOfRangeException: Index was outside the bounds of the array.
UnityEngine.UIElements.TextCoreHandle.GetLineHeight (System.Int32 characterIndex, UnityEngine.UIElements.MeshGenerationContextUtils+TextParams textParams, System.Single textScaling, System.Single pixelPerPoint) (at <0713f2bf9762492888a6ba6ef8e57ae8>:0)
UnityEngine.UIElements.TextInputBaseField`1+TextInputBase[TValueType].DrawWithTextSelectionAndCursor (UnityEngine.UIElements.MeshGenerationContext mgc, System.String newText, System.Single pixelsPerPoint) (at <0713f2bf9762492888a6ba6ef8e57ae8>:0)
UnityEngine.UIElements.TextInputBaseField`1+TextInputBase[TValueType].OnGenerateVisualContent (UnityEngine.UIElements.MeshGenerationContext mgc) (at <0713f2bf9762492888a6ba6ef8e57ae8>:0)
UnityEngine.UIElements.VisualElement.InvokeGenerateVisualContent (UnityEngine.UIElements.MeshGenerationContext mgc) (at <0713f2bf9762492888a6ba6ef8e57ae8>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)```
Thanks