Advertisement
Guest User

Untitled

a guest
Jan 17th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5.  
  6. public class PauseMenu : MonoBehaviour
  7. {
  8. public Transform pause;
  9.  
  10.  
  11. void Start()
  12. {
  13. Cursor.lockState = CursorLockMode.Locked;
  14. Cursor.visible = false;
  15. }
  16.  
  17. void Update()
  18. {
  19. if (Input.GetKeyDown(KeyCode.Escape))
  20.  
  21. {
  22. if (pause.gameObject.activeInHierarchy == false)
  23. {
  24. Camera.main.GetComponent<CameraController>().enabled = false;
  25. Time.timeScale = 0;
  26. pause.gameObject.SetActive(true);
  27. Cursor.visible = true;
  28.  
  29.  
  30. }
  31. else
  32. {
  33. Camera.main.GetComponent<CameraController>().enabled = true;
  34. Time.timeScale = 1;
  35. pause.gameObject.SetActive(false);
  36. Cursor.visible = false;
  37.  
  38. }
  39.  
  40. }
  41. if (pause.gameObject.activeInHierarchy == false)
  42. {
  43. Camera.main.GetComponent<CameraController>().enabled = true;
  44. Time.timeScale = 1;
  45. Cursor.visible = false;
  46.  
  47. }
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement