- Home /
Problem with GUI.Button and other GUI items
Hello. As long as i test my code in the editor everything is great, but when i build the exe file and run it the Buttons dont disappear like in the editor. The functionality is still the same.
var site:int = 0;
function OnGUI(){
if(site==0){
if(GUI.Button(Rect(0,0,120,30),"Button 1")){
site = 1;
}
}
else if(site==1){
if(GUI.Button(Rect(0,40,120,30),"Button 2")){
site = 2;
}
}
}
In the editor:
There is "Button 1". After clicking on it "Button 1" disappears and "Button 2" appears. After clicking on "Button 2" this button disapears and there is no button anymore.
In the .exe:
There is "Button 1". After clicking on it "Button 2" appears and you can also see "Button 1" (without any functionality). After clicking on "Button 2" you can still see both buttons.
There is the same problem with other items like GUI.TextField, GUI.TextArea and GUI.Label.
I hope someone can help me with my little problem.
Answer by dvidunis · Mar 31, 2012 at 01:18 PM
in the example for the button you have to change: site = 2; to: site = 0;
I use site=2 to show no buttons anymore, but they are still drawn both and that is my problem. I want them to disappear but they disappear only in the editor and not in the exe.