-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPause.cs
59 lines (49 loc) · 1.35 KB
/
Pause.cs
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
50
51
52
53
54
55
56
57
58
59
using UnityEngine;
using System.Collections;
public class Pause : MonoBehaviour
{
public GameObject Canvas;
public GameObject pause;
//public GameObject MainMenu;
private bool paused = false;
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
//This script shows the pause menu if the player presses the escape key
//Firstly it stops game time and shows the menus as well as bring the mouse back
void Update ()
{
if(Input.GetKeyDown("escape"))
{
paused = !paused;
}
if(paused)
{
Canvas.SetActive(true);
//MainMenu.SetActive(true);
Time.timeScale = 0;
Cursor.visible = true;
pause.SetActive(true);
}
//And if the player was to pressed escape or continue then the pause menu will hide and time will continue
if (!paused)
{
Canvas.SetActive(false);
// MainMenu.SetActive(false);
Time.timeScale = 1;
Cursor.visible = false;
pause.SetActive(false);
}
}
public void HidePauseMenu()
{
Canvas.SetActive(false);
// MainMenu.SetActive(false);
Time.timeScale = 1;
Cursor.visible = false;
pause.SetActive(false);
paused = false;
}
}