Advertisement
Guest User

New pause

a guest
Apr 22nd, 2014
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. public class pauseMenu : MonoBehaviour
  2. {
  3. public GUISkin myskin;
  4.  
  5. private Rect windowRect;
  6. private bool paused = false , waited = true;
  7.  
  8. private void Start()
  9. {
  10. windowRect = new Rect(Screen.width /2 - 100, Screen.height /2 - 100, 200, 200);
  11. }
  12.  
  13. private void waiting()
  14. {
  15. waited = true;
  16. }
  17.  
  18. private void update()
  19. {
  20. if (waited)
  21. if (Input.GetKey(KeyCode.Escape) || Input.GetKey(KeyCode.P))
  22. {
  23. if (paused)
  24. paused = false;
  25. else
  26. paused = true;
  27.  
  28. waited = false;
  29. Invoke("waiting",0.3f);
  30. }
  31.  
  32. if (paused)
  33. Time.timeScale = 0;
  34. else
  35. Time.timeScale = 1;
  36.  
  37. }
  38.  
  39. private void OnGUI()
  40. {
  41. if (paused)
  42. windowRect = GUI.Window (0, windowRect, windowFunc, "Pause Menu");
  43. }
  44.  
  45. private void windowFunc(int id)
  46. {
  47. if (GUILayout.Button("Resume"))
  48. {
  49. paused = false;
  50. }
  51. GUILayout.BeginHorizontal ();
  52. if (GUILayout.Button("Options"))
  53. {
  54.  
  55. }
  56. if (GUILayout.Button("Quit"))
  57. {
  58.  
  59. }
  60. GUILayout.EndHorizontal ();
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement