-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPauseManager.cs
More file actions
49 lines (36 loc) · 833 Bytes
/
Copy pathPauseManager.cs
File metadata and controls
49 lines (36 loc) · 833 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using UnityEngine;
public class PauseManager : MonoBehaviour
{
public GameObject pauseMenuUI;
private bool isPaused = false;
void Start()
{
if (pauseMenuUI != null)
{
pauseMenuUI.SetActive(false);
}
}
void Update()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
TogglePause();
}
}
public void TogglePause()
{
isPaused = !isPaused;
if (pauseMenuUI != null)
{
pauseMenuUI.SetActive(isPaused);
}
Time.timeScale = isPaused ? 0f : 1f;
}
public void QuitGame()
{
Application.Quit();
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
#endif
}
}