New UI system 4.6, how to change font color?

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:

When you create a button there are actually two objects being created, one for the button background image that has the Button component attached and a child object for the text representation that has the Text component attached.

You have to change the color in the Text component of the child object in order to change the button label color.

If you want to change the label color only when the button is pressed or on mouse hover, you have two options: use the animation transition in the Button component and animate the color of the child object’s text component or create a custom script. In my opinion, using the animation transitions is the easiest option.

Although this question is a year old and has an answer, I want to add my solution for the files as I feel it is still relevant. I created a script that copies the button’s current color into any child Graphic component, i.e. text or images.

As the button’s “current color” resulting from its tint transition can not be obtained from the Button, the relevant trick is to access the button’s CanvasRenderer instead. This component contains a color property which holds the current transition color:

void Update () 
   	//target is any Graphic component (Text, Image, ...)

I made a simple drag and drop ready script, that can be downloaded on my website. Usage: Create a button that contains text and/or image child elements. Drop my script to each child of the button (text, image, …) that you like to have the button’s color state adopted.

Edit: Fixed to use targetGraphic’s renderer instead of buttons renderer which is (at least) required in Unity 5.3.1f1+.