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.
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
}
}