I am Getting The: GUI Error: You are pushing more GUIClips than you are popping. Make sure they are balanced) Error
I think Its Because Im Using a If statement in side OnGUI. If not I have No Idea Where to Put GUI.EndGroup();
function OnGUI()
{
//this is the width that the foreground bar should be
var P1ManaWidth:float = (P1currentMana/100) * P1manaFGMaxWidth;
// Debug.Log("P1 current health " + P1currentMana);
//a spacing variable to help us position the mana
var gapMana:int = 70;// gap from top
GUI.BeginGroup(new Rect (Screen.width/8 - P1manaBGN.width,
gapMana, P1manaBGN.width, P1manaBGN.height));
GUI.DrawTexture(Rect (0,0, P1manaBGN.width, P1manaBGN.height), P1manaBGN);
GUI.BeginGroup(new Rect(0,0, P1ManaWidth, P1manaFGN.height));//effects red bar
GUI.DrawTexture(Rect(0,0, P1manaFGN.width, P1manaFGN.height), P1manaFGN);
GUI.EndGroup();
GUI.EndGroup();
//this is the width that the foreground bar should be
var P1HealthWidth:float = (P1currentHealth/100) * P1healthFGMaxWidth;
// Debug.Log("P1 current health " + P1currentHealth);
//a spacing variable to help us position the health
var gapHealth:int = 50;// gap from top
if (P1Poisoned == true)
{
GUI.BeginGroup(new Rect (Screen.width/8 - P1healthBGN.width,
gapHealth, P1healthBGN.width, P1healthBGN.height));
GUI.DrawTexture(Rect (0,0, P1healthBGN.width, P1healthBGN.height), P1healthBGN);
GUI.BeginGroup(new Rect(0,0, P1HealthWidth, P1healthFGP.height));//effects red bar
GUI.DrawTexture(Rect(0,0, P1healthFGP.width, P1healthFGP.height), P1healthFGP);
}
if (P1Poisoned == false)
{
GUI.BeginGroup(new Rect (Screen.width/8 - P1healthBGN.width,
gapHealth, P1healthBGN.width, P1healthBGN.height));
GUI.DrawTexture(Rect (0,0, P1healthBGN.width, P1healthBGN.height), P1healthBGN);
GUI.BeginGroup(new Rect(0,0, P1HealthWidth, P1healthFGN.height));//effects red bar
GUI.DrawTexture(Rect(0,0, P1healthFGN.width, P1healthFGN.height), P1healthFGN);
}
GUI.EndGroup();
}