x


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.

more ▼

asked Mar 31 '12 at 09:49 AM

Kaytee86 gravatar image

Kaytee86
0 1 1

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

in the example for the button you have to change: site = 2; to: site = 0;

more ▼

answered Mar 31 '12 at 01:18 PM

dvidunis gravatar image

dvidunis
28 3 5 6

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.

Apr 01 '12 at 03:13 PM Kaytee86
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3694
x790
x157
x151
x56

asked: Mar 31 '12 at 09:49 AM

Seen: 369 times

Last Updated: Apr 01 '12 at 03:13 PM