-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPauseGUI.js
45 lines (36 loc) · 1.05 KB
/
PauseGUI.js
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
var gamePaused : boolean = false;
private var buttonWidth:int = 200;
private var buttonHeight:int = 50;
private var spacing:int = 100;
private var buttonSpacing:int = 60;
function Start () {
}
function Update(){
if (Input.GetKeyDown(KeyCode.Escape)){
/*if(gamePaused){
Time.timeScale = 1;
gamePaused = false;
}*/
if(!gamePaused){
Time.timeScale = 0;
gamePaused = true;
}
}
pause = Input.GetButtonDown("Pause");
}
function OnGUI(){
if(gamePaused){
if(GUI.Button(Rect(Screen.width/2 - buttonWidth/2, Screen.height/2 - buttonHeight , buttonWidth, buttonHeight), "Resume game")){
Time.timeScale = 1;
gamePaused = false;
}
if(GUI.Button(Rect(Screen.width/2 - buttonWidth/2, Screen.height/2 - buttonHeight + buttonSpacing, buttonWidth, buttonHeight), "Main menu")){
Application.LoadLevel("GameMenu");
Time.timeScale = 1;
gamePaused = false;
}
if(GUI.Button(Rect(Screen.width/2 - buttonWidth/2, Screen.height/2 - buttonHeight + buttonSpacing*2, buttonWidth, buttonHeight), "Exit")){
Application.Quit();
}
}
}