Advertisement
CakeMeister

PauseMenu phan 7

Jun 29th, 2017
1,763
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.97 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.SceneManagement;
  5.  
  6. public class PauseMenu : MonoBehaviour {
  7.  
  8.     public bool pause = false;
  9.     public GameObject pauseUI;
  10.  
  11.     // Use this for initialization
  12.     void Start () {
  13.         pauseUI.SetActive(false);
  14.     }
  15.    
  16.     // Update is called once per frame
  17.     void Update () {
  18.        
  19.         if (Input.GetKeyDown(KeyCode.Escape))
  20.         {
  21.             pause = !pause;
  22.  
  23.         }
  24.  
  25.         if (pause)
  26.         {
  27.             pauseUI.SetActive(true);
  28.             Time.timeScale = 0;
  29.         }
  30.  
  31.         if (pause == false)
  32.         {
  33.             pauseUI.SetActive(false);
  34.             Time.timeScale = 1;
  35.         }
  36.  
  37.      
  38.     }
  39.     public void resume()
  40.     {
  41.         pause = false;
  42.     }
  43.  
  44.     public void restart()
  45.     {
  46.         SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
  47.     }
  48.  
  49.     public void quit()
  50.     {
  51.         Application.Quit();
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement