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 Bug: "Trying to add TextControl Input Caret"

Discussion in 'UGUI & TextMesh Pro' started by dadude123, Mar 20, 2019.

  1. dadude123

    dadude123

    Joined:
    Feb 26, 2014
    Posts:
    789
    When creating an input field that is auto sized to the content this happens:

    Code (CSharp):
    1. Trying to add TextControl Input Caret (TMPro.TMP_SelectionCaret) for graphic rebuild while we are already inside a graphic rebuild loop. This is not supported.
    2. UnityEngine.RectTransform:set_anchorMin(Vector2)
    3. TMPro.TMP_InputField:AssignPositioningIfNeeded() (at Library/PackageCache/com.unity.textmeshpro@1.3.0/Scripts/Runtime/TMP_InputField.cs:2742)
    4. TMPro.TMP_InputField:AdjustRectTransformRelativeToViewport(Vector2, Single, Boolean) (at Library/PackageCache/com.unity.textmeshpro@1.3.0/Scripts/Runtime/TMP_InputField.cs:3026)
    5. TMPro.TMP_InputField:GenerateCaret(VertexHelper, Vector2) (at Library/PackageCache/com.unity.textmeshpro@1.3.0/Scripts/Runtime/TMP_InputField.cs:2834)
    Version: 2018.3.4f1


    Is there another intended way to make a text field that grows with the input?
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Take a look at the following thread / post which contains changes to the TMP Input Field to support Layout Components.

    Note the structure of the TMP Input Field will need to be edited / modified as per that post as well.
     
    dadude123 likes this.
  3. mitaywalle

    mitaywalle

    Joined:
    Jul 1, 2013
    Posts:
    247
    Hello! in Unity 2019.2.2f1 I'm getting this error, when Set Input-text rectTransform.sizeDelta and, I supose then in same function-context set ScrollRect.normalizedPosition. Can I somehow disable caret with no editing TMP-code?
    Here's code:
    Code (CSharp):
    1.     private void Update()
    2.     {
    3.         if (!RebuildText) return;
    4.      
    5.         Input.textComponent.rectTransform.sizeDelta = Input.textComponent.GetPreferredValues();
    6.         InputBtn.sizeDelta = new Vector2(Input.textComponent.rectTransform.sizeDelta.x, InputBtn.sizeDelta.y);
    7.         var pos = Input.textComponent.rectTransform.localPosition;
    8.         Input.textComponent.rectTransform.localPosition = new Vector3(0f, pos.y, pos.z);
    9.         sRect.horizontalNormalizedPosition = 1f;
    10.         RebuildText = false;
    11.     }
    - RebuildText flag is only set from Input.onSubmit and Input.onDeselect events.
    - label's raycastTarget disabled, cause printing starts by "text_bg"-button press
    - there's no layout Components on label or Input or their parents
    Here's setup:
    - error http://prntscr.com/slnat4
    - hieraerchy http://prntscr.com/sln8jh
    - Input http://prntscr.com/sln93z
    - label http://prntscr.com/sln9io

    Can I remove error, or may be fully disable caret?
     
    Last edited: Nov 18, 2020