- Home /
Help with OnGUI ... multiple boxes showing?
I've been trying to display a screen which shows the character's information, and if you click on a certain button, it moves to the next screen. However, when I click on the button, both boxes end up showing, but if you click again then it goes away.
Here's my code:
function OnGUI(){
if(showCharacterInfo == true){
GUI.Box(Rect(Screen.width-260,Screen.height/2-125,250,250), "Character");
if(GUI.Button(Rect(Screen.width-93, Screen.height/2+92, 80, 30), "Stats")){
showCharacterInfo = false;
showStats = true;
}
}
}
Any explanation for why this happens?
Answer by Slobdell · Aug 02, 2013 at 06:34 PM
You probably have the same script attached multiple times to the same object, or different objects. There's probably two identical boxes at first as well but you don't notice until one of them changes and they look different.
Yes, that was the problem. I had the same script on one of the object's children ... thank you.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Hiding OnGUI? 1 Answer
Where do I assign GUI scripts? 1 Answer
Help! Why doesn't this work? GUI/Static vars Help! Javascript 1 Answer
Camera rotation 0 Answers