Change button text color on different button events

Hi hi,

I feel like the solution to this should be rather straightforward but I can’t figure it out. I’m trying to change the color of a button TEXT depending on what state the button is currently in (normal, highlighted, selected…). I found this answer from 9 years ago: How To Change Color Of Text On UI When It's Selected | Unity 4.6 - #4 by system that recommend to use ISelectHandler and IDeselectHandler to do stuff when the button is selected/deselected, but it seems these interfaces don’t exist in Unity 6 anymore. Any other post/tutorial I could find was only about implementing behavior when a button is clicked, nothing about the other states.

I assume there is already some sort of event happening when interacting with a button, as we can define what colors it turns into when changing states:


Any way to expose that and add my text color change logic to it?

They still exist. They’re part of the UI package itself now: Namespace UnityEngine.EventSystems | Unity UI | 3.0.0-exp.4

1 Like

Oh that’s awesome, thank you so much! :kissing_closed_eyes:

(although I assume you meant to write they’re part of the EventSystems package, not the UI one?)

I mean based on that link they are inside the UI package, just in the UnityEngine.EventSystem namespace.

Oh my bad I didn’t realize it was the doc for the UI package. Thanks again!