Search Unity

Question TMP (Text Mesh Pro ) color changing through script

Discussion in 'UGUI & TextMesh Pro' started by kisstp2006, Mar 11, 2023.

  1. kisstp2006

    kisstp2006

    Joined:
    Jan 9, 2023
    Posts:
    1
    Hello, Can someone help me? I have a script that shows a white background when the mouse over a button, and for that the text on the button should be black, and I would like to solve this with a script. and here is the code I wrote so far:
    upload_2023-3-11_22-39-31.png
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,695
    Two possible choices:

    - change the
    .color
    property on the TMPro object in question (See fonts for limitations)

    - inject HTML into the string to colorize certain letters in the font

    Beyond that, remember that photographs of code are not a thing.

    If you post a code snippet, ALWAYS USE CODE TAGS:

    How to use code tags: https://forum.unity.com/threads/using-code-tags-properly.143875/