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.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

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:
    15
    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:
    530
    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:
    15
    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