Unity Ninja Unity 3D Forum
To have exclusive access to all downloads, recourses and links within this forum, a free registered account is required. Just a heads up Wink

You are not connected. Please login or register

Unity Ninja Unity 3D Forum » FREE Project Downloads & Recources » Scripts » Pause Menu

Pause Menu

View previous topic View next topic Go down  Message [Page 1 of 1]

1 Pause Menu on Sat Aug 19, 2017 1:15 am

PitbullM

avatar
{SUPER MEMBER}-LV.4
{SUPER MEMBER}-LV.4
Hello to all
I would like to share a small and useful script.
Hope i can serve you.
You can still implement it with additional functions ......
But you have to think about it;)
Hi and good fun.

Code:
/*
 ----    Easy Pause menu Ver.1.5    -------
 ----    by Digital_Pitbull ® 2017  -------
*/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PMenu : MonoBehaviour {

    #region Variable

    private bool isPaused = false;
    private bool isOption = false;
    public GUISkin customSkin;
    [Tooltip("Write Your level to Load")]
    public string ReloadLevel = "";
    [Tooltip("Write Your Project Name")]
    public string NameProject = "";

    #endregion
    #region Start

    void Start()
    {

        Cursor.visible = false;
        Cursor.lockState = CursorLockMode.Locked;
    }
    #endregion
    #region Update
    void Update()
    {

        if (Input.GetKeyDown(KeyCode.Escape))
            isPaused = !isPaused;
           //isOption = false;


        if (isPaused)
        {
            Time.timeScale = 0f;
            Cursor.visible = true;
            Cursor.lockState = CursorLockMode.None;
        }
        else
        {
            isOption = false;
            Time.timeScale = 1.0f;
            Cursor.visible = false;
            Cursor.lockState = CursorLockMode.Locked;
        }
        #endregion
    }
    #region OnGUI
    void OnGUI()
    {


        GUI.skin = customSkin;

        if (isPaused)
        {
            GUI.Box(new Rect(Screen.width / 2 - 260, 5, 510, 80), "" + NameProject);

            if (GUI.Button(new Rect(Screen.width / 2 - 60, Screen.height / 2 - 60, 100, 40), "Continue"))
            {
                isPaused = false;
                isOption = false;
            }


            if (GUI.Button(new Rect(Screen.width / 2 - 60, Screen.height / 2 + 00, 100, 40), "Restart"))
            {

                Application.LoadLevel(ReloadLevel);
            }

            if (GUI.Button(new Rect(Screen.width / 2 - 60, Screen.height / 2 + 60, 100, 40), "Option"))
            {

                isOption = !isOption;


            }

            if (GUI.Button(new Rect(Screen.width / 2 - 60, Screen.height / 2 + 120, 100, 40), "Quit"))
            {
                Application.Quit();

            }
        }

        if (isOption)
        {
            GUI.Box(new Rect(20, 10, 200, 500), "Graphics Resolution");

            if (GUI.Button(new Rect(70, 60, 80, 20), "Fastest"))
            {
                QualitySettings.currentLevel = QualityLevel.Fastest;
            }
            // Make the second button.
            if (GUI.Button(new Rect(70, 90, 80, 20), "Fast"))
            {
                QualitySettings.currentLevel = QualityLevel.Fast;
            }

            // Make the second button.
            if (GUI.Button(new Rect(70, 120, 80, 20), "Simple"))
            {
                QualitySettings.currentLevel = QualityLevel.Simple;
            }

            // Make the second button.
            if (GUI.Button(new Rect(70, 150, 80, 20), "Good"))
            {
                QualitySettings.currentLevel = QualityLevel.Good;
            }

            // Make the second button.
            if (GUI.Button(new Rect(70, 180, 80, 20), "Beauthiful"))
            {
                QualitySettings.currentLevel = QualityLevel.Beautiful;
            }

            // Make the second button.
            if (GUI.Button(new Rect(70, 210, 80, 20), "Fantastic"))
            {
                QualitySettings.currentLevel = QualityLevel.Fantastic;

            }
        }

        #endregion
    }


}

View user profile

View previous topic View next topic Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum