TMP (Text Mesh Pro ) color changing through script

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:

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: Using code tags properly