When my game starts i have some code which draws 2 textures that I adjust the length of to display stamina. It works perfect.
void OnGUI() {
GUI.DrawTexture (new Rect (10, 10, curStaminaBG, barHeights), staminaBarBG);
GUI.DrawTexture (new Rect (10, 10, displayStamina, barHeights), staminaBar);
}
What I would like to able to do is to change the texture when say a bool is set to true. So if I take this line from the above:
GUI.DrawTexture (new Rect (10, 10, displayStamina, barHeights), staminaBar);
When my bool goes to true I want it to change to:
GUI.DrawTexture (new Rect (10, 10, displayStamina, barHeights), newBackground);
Seeing as how they are drawn in the ongui function can I even do that?