Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class PauseMenu2 : MonoBehaviour
- {
- public bool Paused = false;
- public bool ShowPauseMenu = false;
- public bool ShowOptionsMenu = false;
- public static float SensitivityX = 1f;
- public static float SensitivityY = 1f;
- public MouseLook PlayerMouseControllerX;
- public MouseLook PlayerMouseControllerY;
- // Use this for initialization
- void Start()
- {
- Paused = false;
- Time.timeScale = 1;
- Screen.lockCursor = true;
- Screen.showCursor = false;
- ShowPauseMenu = false;
- PlayerMouseControllerX.sensitivityX = SensitivityX;
- PlayerMouseControllerY.sensitivityY = SensitivityY;
- }
- // Update is called once per frame
- void Update()
- {
- if (Input.GetKeyDown(KeyCode.Escape))
- {
- if (!Paused)
- {
- Paused = true;
- Time.timeScale = 0;
- Screen.lockCursor = false;
- Screen.showCursor = true;
- ShowPauseMenu = true;
- PlayerMouseControllerX.sensitivityX = 0;
- PlayerMouseControllerY.sensitivityY = 0;
- }
- else if (Paused)
- {
- Paused = false;
- Time.timeScale = 1;
- Screen.lockCursor = true;
- Screen.showCursor = false;
- ShowPauseMenu = false;
- PlayerMouseControllerX.sensitivityX = SensitivityX;
- PlayerMouseControllerY.sensitivityY = SensitivityY;
- }
- }
- }
- void OnGUI()
- {
- {
- if (ShowPauseMenu)
- {
- // Make a background box
- GUI.Box(new Rect(10, 10, 650, 300), "Paused");
- // Make the resume button
- if (GUI.Button(new Rect(290, 100, 80, 20), "Resume"))
- {
- ShowPauseMenu = false;
- Time.timeScale = 1;
- Screen.showCursor = false;
- Screen.lockCursor = true;
- }
- // Make the second button that will kill the process
- if (GUI.Button(new Rect(290, 200, 80, 20), "Quit"))
- {
- Application.Quit();
- }
- if (GUI.Button(new Rect(290, 150, 80, 20), "Options"))
- {
- ShowPauseMenu = false;
- ShowOptionsMenu = true;
- }
- }
- else if (ShowOptionsMenu)
- {
- GUI.Box(new Rect(10, 10, 650, 300), "Options");
- GUI.Label(new Rect(150, 200, 150, 20), "Sensitivty X: (" + SensitivityX.ToString() + ")");
- GUI.Label(new Rect(150, 225, 150, 20), "Sensitivty Y: (" + SensitivityY.ToString() + ")");
- SensitivityX = GUI.HorizontalSlider(new Rect(200, 200, 150, 20), SensitivityX, 0.1f, 20f);
- SensitivityY = GUI.HorizontalSlider(new Rect(200, 225, 150, 20), SensitivityY, 0.1f, 20f);
- //If the "Return" button is pressed, go back to the main menu
- if (GUI.Button(new Rect(209, 100, 80, 20), "Return"))
- {
- ShowPauseMenu = true;
- ShowOptionsMenu = false;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment