GUI Window problem

Hi all,

i have worked with unity before six months. but am trying and working with GUI windows. it’s giving trouble to me about 2 hours. here is my code

using UnityEngine;
using System.Collections;

public class Menu : MonoBehaviour {
	
	public GUIStyle background = new GUIStyle();
	private bool menus = true;
	public Rect window1 = new Rect(3,3,Screen.width-3,Screen.height-3);
	
	void OnGUI()
	{
		GUI.Label(new Rect(0,0,Screen.width,Screen.height)," ",background);	
		
		if(menus)
		{
			if(GUI.Button(new Rect((Screen.width)/2-50,(Screen.height)/2-60,100,30),"Play Game"))
			{
				Application.LoadLevel(1);
			}
		
			else if(GUI.Button(new Rect((Screen.width)/2-50,(Screen.height)/2-20,100,30),"Settings"))
			{
				window1 = GUI.Window(1,window1,settingsWindow,"");
				menus = false;
			}
		
			else if(GUI.Button(new Rect((Screen.width)/2-50,(Screen.height)/2+20,100,30),"Credits"))
			{
				
			}
		}
	}
	
	void settingsWindow(int windowID)
	{
		GUI.Label(new Rect(50,50,100,30),"Volume");
	}
}

i have worked before in the same thing. here the problem is the new window is not opening. can any one say what am doing wrong??
Thank you in advance.

The problem here is that you call the settingsWindow function ones. After setting the menus boolean to false, the function never gets called again, therefore is never drawn on the screen again.

I have called the window directly when click on button in my question. thats not the correct way. here we need to set a boolean value for that,if it is correct we need to open the window.

here is the correct code…

using UnityEngine;
using System.Collections;

public class Menu : MonoBehaviour {

    public GUIStyle background = new GUIStyle();
    private bool menus = true;
    private bool settingsWin = false;
    public Rect window1 = new Rect(3,3,Screen.width-3,Screen.height-3);

    void OnGUI()
    {
        GUI.Label(new Rect(0,0,Screen.width,Screen.height)," ",background); 

        if(menus)
        {
            if(GUI.Button(new Rect((Screen.width)/2-50,(Screen.height)/2-60,100,30),"Play Game"))
            {
                Application.LoadLevel(1);
            }

            else if(GUI.Button(new Rect((Screen.width)/2-50,(Screen.height)/2-20,100,30),"Settings"))
            {
                settingsWin = true;
                menus = false;
            }

            else if(GUI.Button(new Rect((Screen.width)/2-50,(Screen.height)/2+20,100,30),"Credits"))
            {

            }
        }
        if(settingsWin)
        {
           window1 = GUI.Window(1,window1,settingsWindow,"");
        }

    }

    void settingsWindow(int windowID)
    {
        GUI.Label(new Rect(50,50,100,30),"Volume");
    }
}