all repos — RPG @ 006fdc724dea4fb9f50a04871f38776841e84439

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    public DialogueManager dm;
 8    void Update()
 9    {
10        if (Input.GetKeyDown(KeyCode.Escape))
11        {
12            if(dm.alreadyTalking == null)
13                ui.showPause(togglePause());
14        }
15        
16    }
17
18    private bool togglePause()
19    {
20        if (Time.timeScale == 1f)
21        {
22            Time.timeScale = 0f;
23            return true;
24        }
25        else
26        {
27            Time.timeScale = 1f;
28            return false;
29        }
30    }
31
32    public void QuitGame()
33    {
34        Time.timeScale = 1f;
35        SceneManager.LoadScene("Menu");
36    }
37
38}