Changing GUI Colors on the fly.

Hello everyone,

How can i change the color of a GUI Element on the fly?
I made a Color Control and i want to let the user see the result color into a LABEL or any other GUI Control,
I tried changing GUI.BackgroundColor, ContentColor and Color but it doesn’t work.

myColor = GetColorFromControl(myColor);
GUI.backgroudColor = myColor;
GUI.contentColor = myColor

Bye.

First we ought to define more precisely what color you’re interested in changing. The GUI.color, GUI.backgroundColor and GUI.contentColor all apply a “tint” as opposed to setting a final color. If you’re ok with that then the most straightforward is to set GUI.color in particular as that will tint all objects after you set the color (text, images, whatever). Setting GUI.contentColor only tints the text (as per the docs).

Let us know if any of that helps, if not then offer some course correction and we’ll get you there!

Two tips:

  1. Don’t wrap code in a quote block, wrap it in a code block for better formatting. I’ve edited your post for you, give it a look.

  2. Post GUI questions in the UnityGUI section as you’re more likely to get help there. I’ll move this thread there now.