Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.SceneManagement;
- public class PauseMenu : MonoBehaviour {
- public GameObject ui;
- public GameObject canvas;
- void Update () {
- if(Input.GetKeyDown(KeyCode.Escape)){
- Toggle();
- }
- }
- public void Toggle(){
- canvas.SetActive(false);
- ui.SetActive(!ui.activeSelf);
- if (ui.activeSelf)
- {
- Time.timeScale = 0f;
- } else
- {
- Time.timeScale = 1f;
- canvas.SetActive(true);
- }
- }
- public void Retry()
- {
- Toggle();
- SceneManager.LoadScene (SceneManager.GetActiveScene().buildIndex);
- }
- public void Menu()
- {
- SceneManager.LoadScene("MainMenu");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement