- Home /
changing text color in GUI.Label
i'm trying to change the color of text in a GUI.Label, but i can't figure out how, the only thing i managed to get is make the text invisible...
Comment
Answer by Ray-Pendergraph · Apr 08, 2011 at 10:53 AM
If you style the label with a copy of GUI.skin.label you can just change the textColor of the particular style mode(s) you want
GUIStyle localStyle = new GUIStyle(GUI.skin.label);
if (somethingBad)
{
localStyle.normal.textColor = Color.red;
}else{
localStyle.normal.textColor = Color.green;
}
that's sort of the quick and dirty way but it works very well most of the time. The 'correct' way is to use custom styles and skins. Many times our buttons don't have text per se so we have to define a separate style with the altered color text.
Answer by zmar0519 · Apr 08, 2011 at 10:14 AM
also GUI.Color
, GUI.BackgroundColor
, and GUI.TintColor
.