- Home /
Changing the color of a GUI element
I can change the color, background color, and content color of the entire GUI, but it seems that is impossible to change the color of any individual GUI element except by changing its background texture.
Is this true?
Answer by Molix · Feb 15, 2011 at 05:10 AM
You can change it for each item. e.g.
void OnGUI() { GUI.color = Color.red; GUILayout.Box( "I'm red" );
GUI.color = Color.yellow; GUILayout.Box( "I'm yellow" );
GUI.color = new Color( 1, 1, 1, 0.5f ); GUILayout.Box( "I'm translucent" );
GUI.color = Color.white; GUILayout.Box( "I'm normal" );
// etc }
Note that the coloring is a multiply, so the base color works best on white / light grayscale. If the base color is black then there will be no apparent effect (since black is 0, multiplying will only give 0).