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 Caret Position Issues - Update Delay and Position Changes with Color Updates

Discussion in 'UGUI & TextMesh Pro' started by Deleted User, Apr 27, 2018.

  1. Deleted User

    Deleted User

    Guest

    I'm trying to use the TMP_InputField for an IDE. As such, I've been trying to add auto-indentation and syntax highlighting.

    Edit: I solved my caretPosition delay issue by using stringPosition instead. I didn't see stringPosition until after coming over the file again. I've found that changing stringPosition will cause the cursor position to change almost instantly.

    Now, I'm having issues with the caret position changing after adding markup to text automatically. When the user types a reserved word, quote, or comment I change the color of the text and while the caret initially stays in the same position. It glitches off to a new location after a delay.

    My guess would that be the stringPosition is not being updated with the markup and that caretPosition polls its position from stringPosition (as my earlier issue showed).

    Side note:
    Is there any way to get the InputField text without the markup? I created my own function to strip it out, but I'd like to avoid duplicating effort.
     
    Last edited by a moderator: Apr 30, 2018
  2. Deleted User

    Deleted User

    Guest

    Ended up with a custom solution to get around it. The caret position was still right, so I iterated through the string to find the right string position for my caret position and used that. I tried using Reflection to access the private GetStringIndexFromCaretPosition function, but that didn't work.

    It seems like it's a bug with the TMP_InputField. Maybe only when Allow Rich Text Editing is off? Since no one else is having similar.

    If there's an existing way to get the text without markup then let me know. Otherwise, someone can close this thread or something.