Advertisement
Guest User

Unity Pause extension

a guest
Apr 18th, 2014
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #pragma strict
  2.  
  3. var paused : boolean = false;
  4. var myCheck : boolean = false;
  5.  
  6. function Start(){
  7.    paused=false;
  8. }
  9.  
  10.  
  11. function Update () {
  12.     if(Input.GetButtonDown( "Pause" ) ) {
  13.     if(!paused) {
  14.     Time.timeScale = 0;
  15.     paused = true;
  16. Screen.lockCursor = false;
  17.     var firstPersonControllerCamera = gameObject.Find("First Person Controller").GetComponent(MouseLook);
  18.     var mainCamera = gameObject.Find("Main Camera").GetComponent(MouseLook);
  19.     firstPersonControllerCamera.enabled = false;
  20.     mainCamera.enabled = false;
  21.  
  22.  
  23.     }else{
  24.     Time.timeScale = 1;
  25.     paused = false;
  26.  
  27. Screen.lockCursor = true;
  28.     firstPersonControllerCamera = gameObject.Find("First Person Controller").GetComponent(MouseLook);
  29.     mainCamera = gameObject.Find("Main Camera").GetComponent(MouseLook);
  30.     firstPersonControllerCamera.enabled = true;
  31.     mainCamera.enabled = true;
  32.  
  33.  
  34.        }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement