I’m trying to make a stamina bar using two GUI.Box that overlap each other. The first one, is behind is a solid black, while the one is in front, which is solid blue and I’m trying to do in a way that the stamina bar (in front) shrinks every time you sprint. My problem is that I can’t seem to change the background color of the GUI.Box. Any suggestions?
Tried doing this:
void OnGUI()
{
GUI.backgroundColor = Color.black;
GUI.Box(new Rect(5, 30, 60, 20), "Stamina");
GUI.Box(new Rect(65, 30, barLength, 20), currentStamina.ToString("0"));
GUI.backgroundColor = Color.blue;
GUI.Box(new Rect(5, 30, 60, 20));
GUI.Box(new Rect(65, 30, barLength, 20), currentStamina.ToString("0"));
}
And because OnGUI goes on its own function, how would I update the length of the box, if I were to press the letter “C” for example?