- Home /
Question by
$$anonymous$$ · Jan 12, 2019 at 01:21 PM ·
c#guicolor change
How do I change the IMGUI Box Color in Script?
So, I want to Display with a IMGUI Box, wether the Fire1 Button is or isn't currently pressed. To make it easier to see, I want the IMGUI Box to change Color: To Green, when Fire1 is pressed, and back to Black when it's not pressed.
How do I achieve this?
void OnGUI () {
if ( Input.GetButton ("Fire1") )
{
GUI.Box(new Rect(10,10,250,120), "Fire1 is pressed Yes"); //IMGUI Box is Black
}
else ()
{
GUI.Box(new Rect(10,10,250,120), "Fire1 is pressed No"); //IMGUI Box should be green
}
}
Comment
Answer by HenBOMB · Jan 12, 2019 at 07:02 PM
void OnGUI () {
if ( Input.GetButton ("Fire1") )
{
GUI.Color = Color.black;
GUI.Box(new Rect(10,10,250,120), "Fire1 is pressed Yes"); //IMGUI Box is Black
}
else ()
{
GUI.Color = Color.green;
GUI.Box(new Rect(10,10,250,120), "Fire1 is pressed No"); //IMGUI Box should be green
}
}
Your answer

Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Multiple Cars not working 1 Answer
RTS rectangle selection system 3 Answers
GUI Label Width & Height 0 Answers
Horizontal slider won't work 1 Answer