Beispiel #1
0
 void ShowQuit()
 {
     if (gameObject.GetComponent(typeof(ConfirmationWindowScript)) == null)
     {
         // Create a confirmationScript
         ConfirmationWindowScript confirmationWindow = gameObject.AddComponent <ConfirmationWindowScript>();
         // Set Description of the confirmation window
         confirmationWindow.description = "Are you sure you wish to quit?";
         // Set Width and Height
         confirmationWindow.SetWidthAndHeight(70, 35);
         // Set the OnConfirm to load the main menu
         confirmationWindow.OnConfirm += () => Application.LoadLevel("Main Menu");
     }
     currentPage = Page.None;
 }
Beispiel #2
0
    void OnGUI()
    {
        // Height and width of the buttons that are going to be created
        const float width  = 150;
        const float height = 30;

        if (showGUI)
        {
            float x = Screen.width / 2 - 50;
            float y = Screen.height / 2;

            // Return button, Destroys the menu
            if (GUI.Button(new Rect(x, y, width, height), "Return"))
            {
                Destroy(this);
            }

            y += 40;
            // Options Button
            if (GUI.Button(new Rect(x, y, width, height), "Options"))
            {
                //display Options
                gameObject.AddComponent <OptionsMenuScript>();
                showGUI = false;
            }

            y += 40;
            // Quit Button
            if (GUI.Button(new Rect(x, y, width, height), "Quit to Main Menu"))
            {
                if (gameObject.GetComponent(typeof(ConfirmationWindowScript)) == null)
                {
                    // Create a confirmationScript
                    ConfirmationWindowScript confirmationWindow = gameObject.AddComponent <ConfirmationWindowScript>();
                    // Set Description of the confirmation window
                    confirmationWindow.description = "Are you sure you wish to quit?";
                    // Set the OnConfirm to load the main menu
                    confirmationWindow.OnConfirm += () => Application.LoadLevel("Main Menu");
                }
                Destroy(this);
            }
        }
    }