x


problem with a pop-up window

Hi all! I've got a problem getting this code to work. The "main menu" is built the way it should be but the pop up window that's expected to appear when "options" button is clicked, does not show up. is there something wrong with my code?

public class Main_menu : MonoBehaviour {

    public Rect windowRect_p =  new Rect ((Screen.width-140)/2-30,(Screen.height-30)/2-30,200,210);

    void OnGUI() {

       GUI.Box (new Rect ((Screen.width-140)/2-30,(Screen.height-30)/2-30,200,210), "Main Menu");

if (GUI.Button (new Rect ((Screen.width-140)/2, (Screen.height-30)/2+90, 140, 30), "Options")) {

         windowRect_p = GUI.Window(0, windowRect_p, perform_Window, "Options");
       }
    }

void perform_Window(int windowID) {
       if(windowID==0){
         if (GUI.Button(new Rect(10, 20, 100, 20), "Sounds"))
            ...;


       }
    }
more ▼

asked Jul 30 '11 at 01:53 PM

Farnaz gravatar image

Farnaz
16 4 5 7

To format as code, select the code and hit the 101010 button above the edit window.

Jul 31 '11 at 12:43 AM DaveA
(comments are locked)
10|3000 characters needed characters left

1 answer: sort newest

What I would do is have the Option button set a boolean var like 'showOptions = true' and have OnGUI check for that, displaying the Options window accordingly. A button in the Options window can set it false to close it.

more ▼

answered Jul 31 '11 at 12:54 AM

DaveA gravatar image

DaveA
26.8k 153 171 257

(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:

x3811
x208
x58

asked: Jul 30 '11 at 01:53 PM

Seen: 921 times

Last Updated: Jul 31 '11 at 12:54 AM