all repos — RPG @ 62a0546261098a7868f5986f21adf997f247852f

Fully functional 3D turn based role playing game coded in C# and base Unity.

Assets/Scripts/Overworld/PauseMenuManager.cs (view raw)

 1using UnityEngine;
 2using UnityEngine.SceneManagement;
 3
 4public class PauseMenuManager : MonoBehaviour
 5{
 6    public OverworldUIManager ui;
 7    
 8    void Update()
 9    {
10        if (Input.GetKeyDown(KeyCode.Escape))
11        {
12            ui.showPause(togglePause());
13        }
14        
15    }
16
17    private bool togglePause()
18    {
19        if (Time.timeScale == 1f)
20        {
21            Time.timeScale = 0f;
22            return true;
23        }
24        else
25        {
26            Time.timeScale = 1f;
27            return false;
28        }
29    }
30
31    public void QuitGame()
32    {
33        Time.timeScale = 1f;
34        SceneManager.LoadScene("Menu");
35    }
36
37}