Guest User

Untitled

a guest
Sep 29th, 2014
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.39 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class PauseMenu2 : MonoBehaviour
  5. {
  6.     public bool Paused = false;
  7.     public bool ShowPauseMenu = false;
  8.     public bool ShowOptionsMenu = false;
  9.     public static float SensitivityX = 1f;
  10.     public static float SensitivityY = 1f;
  11.     public MouseLook PlayerMouseControllerX;
  12.     public MouseLook PlayerMouseControllerY;
  13.  
  14.     // Use this for initialization
  15.     void Start()
  16.     {
  17.         Paused = false;
  18.         Time.timeScale = 1;
  19.         Screen.lockCursor = true;
  20.         Screen.showCursor = false;
  21.         ShowPauseMenu = false;
  22.         PlayerMouseControllerX.sensitivityX = SensitivityX;
  23.         PlayerMouseControllerY.sensitivityY = SensitivityY;
  24.     }
  25.  
  26.     // Update is called once per frame
  27.     void Update()
  28.     {
  29.         if (Input.GetKeyDown(KeyCode.Escape))
  30.         {
  31.             if (!Paused)
  32.             {
  33.                 Paused = true;
  34.                 Time.timeScale = 0;
  35.                 Screen.lockCursor = false;
  36.                 Screen.showCursor = true;
  37.                 ShowPauseMenu = true;
  38.                 PlayerMouseControllerX.sensitivityX = 0;
  39.                 PlayerMouseControllerY.sensitivityY = 0;
  40.             }
  41.             else if (Paused)
  42.             {
  43.                 Paused = false;
  44.                 Time.timeScale = 1;
  45.                 Screen.lockCursor = true;
  46.                 Screen.showCursor = false;
  47.                 ShowPauseMenu = false;
  48.                 PlayerMouseControllerX.sensitivityX = SensitivityX;
  49.                 PlayerMouseControllerY.sensitivityY = SensitivityY;
  50.             }
  51.         }
  52.     }
  53.     void OnGUI()
  54.     {
  55.        
  56.         {
  57.             if (ShowPauseMenu)
  58.             {
  59.                 // Make a background box
  60.                 GUI.Box(new Rect(10, 10, 650, 300), "Paused");
  61.  
  62.                 // Make the resume button
  63.                 if (GUI.Button(new Rect(290, 100, 80, 20), "Resume"))
  64.                 {
  65.                     ShowPauseMenu = false;
  66.                     Time.timeScale = 1;
  67.                     Screen.showCursor = false;
  68.                     Screen.lockCursor = true;
  69.                 }
  70.                 // Make the second button that will kill the process
  71.                 if (GUI.Button(new Rect(290, 200, 80, 20), "Quit"))
  72.                 {
  73.                     Application.Quit();
  74.                 }
  75.                 if (GUI.Button(new Rect(290, 150, 80, 20), "Options"))
  76.                 {
  77.                     ShowPauseMenu = false;
  78.                     ShowOptionsMenu = true;
  79.                 }
  80.             }
  81.             else if (ShowOptionsMenu)
  82.             {
  83.                 GUI.Box(new Rect(10, 10, 650, 300), "Options");
  84.                 GUI.Label(new Rect(150, 200, 150, 20), "Sensitivty X: (" + SensitivityX.ToString() + ")");
  85.                 GUI.Label(new Rect(150, 225, 150, 20), "Sensitivty Y: (" + SensitivityY.ToString() + ")");
  86.                 SensitivityX = GUI.HorizontalSlider(new Rect(200, 200, 150, 20), SensitivityX, 0.1f, 20f);
  87.                 SensitivityY = GUI.HorizontalSlider(new Rect(200, 225, 150, 20), SensitivityY, 0.1f, 20f);
  88.                 //If the "Return" button is pressed, go back to the main menu
  89.                 if (GUI.Button(new Rect(209, 100, 80, 20), "Return"))
  90.                 {
  91.                     ShowPauseMenu = true;
  92.                     ShowOptionsMenu = false;
  93.                 }
  94.             }
  95.         }
  96.     }
  97. }
Advertisement
Add Comment
Please, Sign In to add comment