How To Change Color Of Text On UI When It's Selected | Unity 4.6

How do I change the font’s color when Normal/HighLighted/Pressed/Disabled in the new UI system for unity 4.6? The Button → Transition → Color Tint will just change the BUTTON’S color, and not the font itself. Any idea on how I could do that? :slight_smile:

Thanks in advance, peace! :slight_smile:

I achieved this with minimal effort by adding a script to my button and implementing ISelectHandler and IDeselectHandler

public class ButtonTextColorChangeScript : MonoBehaviour, ISelectHandler, IDeselectHandler {

    void ISelectHandler.OnSelect(BaseEventData eventData)
        gameObject.GetComponentInChildren<Text>().color = new Color(255, 255, 255, 255);


    public void OnDeselect(BaseEventData eventData)
        gameObject.GetComponentInChildren<Text>().color = new Color(0, 0, 0, 255);


You can do that making animation clips for each state (changing the background image and text color) and setting the Transition to Animation. That’s the most flexible way of doing things with the Button component, each animation could affect multiple objects and values.

Another option would be to remove the Button component and add an Event Trigger component. With that component you can setup callbacks for each UI event, and those callbacks can trigger functions in any gameobject. This let you do more stuff than the “Transition → Animation” method since you’re not tied to animations, but it takes some extra work to set it all up.

To change the color of the text itself.

Select the Text under the Button in the canvas which looks like following : 


And then you can change the color here as shown below :