Changing text color at runtime

How do I change text color via script, while the game is running? Using
text.color = Color.red;
simply does not work.

GetComponent(Text).color = Color.red;

–Eric

Thanks, Eric, but the line of code you posted has no effect. My “text” var is of “Text” type already anyway.

I want to mention that I can’t change the text color via colorpicker in Scene window while the game is running.

Works fine here.

–Eric

Whoops. It was because of Animator component attached on a parent (button).