Hi,
I have figured out how to tint the GUI.Box or "fatigue bar" for my in-game gui. My question is: how can I make the GUI.Box green or red or blue or whatever besides grey and 'tinted'?
Texture2D FatigueEmpty; void OnGUI() { Vector2 size = new Vector2(275, 11.5f); // FATIGUE - Green GUI.BeginGroup( new Rect ( size.x, 0, 256, size.y)); GUI.Box( new Rect ( 0, 0, 256, size.y), FatigueEmpty); GUI.BeginGroup( new Rect ( 0, 0, 256 * fatigue, size.y)); Color FatigueColor = GUI.color; FatigueColor.a = 0.5f; GUI.color = FatigueColor; // 'tint' the Fatigue Bar GUI.Box(new Rect ( 0, 0, 256, size.y), FatigueEmpty); GUI.EndGroup(); GUI.EndGroup(); FatigueColor.a = 1f; GUI.color = FatigueColor; // change it back }
`
And this below:
void OnGUI()
{
Vector2 size = new Vector2(275, 11.5f);// FATIGUE - Green GUI.BeginGroup( new Rect ( size.x, 0, 256, size.y)); GUI.Box( new Rect ( 0, 0, 256, size.y), FatigueEmpty); GUI.BeginGroup( new Rect ( 0, 0, 256 * fatigue, size.y)); Color FatigueColor = GUI.color; FatigueColor = Color.green; GUI.color = FatigueColor; GUI.Box(new Rect ( 0, 0, 256, size.y), FatigueEmpty); GUI.EndGroup(); GUI.EndGroup(); FatigueColor = Color.grey; // The default color GUI.color = FatigueColor; // change it back
}
`
Using the Color type, 'FatigueColor' I tried to store a Color.green into it. then transfer that to the GUI.color so that the following GUI.Box can use it..Didn't work. I also tried FatigueColor.g (for green) in the same scheme as FatigueColor.a = 0.5f but that didn't work either..
Could someone help me figure out how to change the color of these boxes?