Search Unity

Question How to change the selection color (TMP)

Discussion in 'UGUI & TextMesh Pro' started by hwk9120, May 23, 2023.

  1. hwk9120

    hwk9120

    Joined:
    May 9, 2023
    Posts:
    17
    Hi, I'm working on a project that uses TMP a lot.

    When I drag some characters on TMP_Text/InputField, I want to change the selection color like this example at the same time.

    https://docs.unity3d.com/ScriptReference/GUISettings-selectionColor.html
    upload_2023-5-23_18-50-18.png



    Can I do this on TMP?
    Also I don't want to insert any rich text tag to implement this function, because I've already use <mark> tag to highlight what I dragged.
     
  2. karliss_coldwild

    karliss_coldwild

    Joined:
    Oct 1, 2020
    Posts:
    601
    How about using the "selection color" setting? Although your comment about <mark> tag slightly confuses me. Are you using TMP Input field the the basic way or are you building some custom text control on top of TMP?


    upload_2023-5-23_15-52-35.png
     
  3. hwk9120

    hwk9120

    Joined:
    May 9, 2023
    Posts:
    17
    As your advice, if I use the InputField setting I can do what I want!

    Yess, what I am doing is typing letters, selecting a sentence and highlighting the selected sentence. The last one is the reason why I use the <mark> tag.

    Thank you:)
     
    Last edited: May 24, 2023