- Home /
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"))
...;
}
}
To format as code, select the code and hit the 101010 button above the edit window.
Answer by DaveA · Jul 31, 2011 at 12:54 AM
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.
Your answer
Follow this Question
Related Questions
Is it possible to have a spectrum analyzer display for each song in a playlist? 1 Answer
What's a great way to make a custom information window pop up 1 Answer
How to set up a gui text box to count inventory items? 1 Answer
Add EditorUI elements when a button is pressed 0 Answers
how to get Gui in OnGUI function to resize with the window? 1 Answer