x


controls displayed on GUI never disappear, ask for help (with short source code)

Hello,

Below is the short source code:

var buttonPressed : boolean = false;

function OnGUI()
{
    if (buttonPressed) 
    {
        GUI.HorizontalSlider(Rect(Screen.width * .5 - 100, Screen.height * .5, 200, 20), 5, -40, 40);
        if (GUI.Button(Rect(Screen.width * .5 - 100, Screen.height * .8, 200, 40), "Press Me")) 
        {
            buttonPressed = !buttonPressed;
        }
    }
    else 
    {
        GUI.VerticalSlider(Rect(Screen.width * .5 - 10, Screen.height * .25 - 100, 20, 200), 5, -40, 40);
        if (GUI.Button(Rect(Screen.width * .5 - 100, Screen.height * .8, 200, 40), "Press Me")) 
        {
            buttonPressed = !buttonPressed;
        }
    }
}

My purpose is: vertical slider and 'press me' button shows, after clicking 'press me' button, horizontal slider and 'press me' button shows (vertical slider should disappear), but the vertical slider never disappears.

Thanks.

more ▼

asked Mar 26 '10 at 01:19 PM

jinfeng gravatar image

jinfeng
1 1 1 1

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

1 answer: sort voted first

It works fine. You may have more than one copy of the script running.

more ▼

answered Mar 26 '10 at 07:04 PM

Eric5h5 gravatar image

Eric5h5
80.3k 42 132 521

Thank you, Eric5h5. Yes, I have more than one copy of the script running.

Mar 27 '10 at 02:56 AM jinfeng
(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:

x3698
x224
x108

asked: Mar 26 '10 at 01:19 PM

Seen: 975 times

Last Updated: Mar 26 '10 at 07:01 PM