Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question Style specific words/characters of Input Field as the user types

Discussion in 'UGUI & TextMesh Pro' started by keenanwoodall, May 15, 2021.

  1. keenanwoodall


    May 30, 2014
    I would like to dynamically style parts of text as it is typed into an input field. The user should not be able to see or modify these tags at any point. Basically I would like programmatic control over the styling of the characters, without exposing the same control to the user.

    The simplest example would be highlighting parts of the text:

    In this scenario, as the user types, any characters that surpass some max amount should be highlighted red to indicate which ones need to be removed for valid input.

    To my knowledge this is currently not possible to achieve. Inserting tags via the onValueChanged messes up the caret position, and using an ITextPreprocessor on the input field's text component results in TMP throwing out of range exceptions (and just breaking in general.)

    I would love some way to style text as it is typed without the tags interfering with the user as they type/navigate text. Is this possible?