add functionality to pause Menu
This commit is contained in:
parent
84cb62559a
commit
0466aebd04
5 changed files with 137 additions and 13 deletions
|
@ -265,7 +265,7 @@ GameObject:
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
m_IsActive: 1
|
m_IsActive: 0
|
||||||
--- !u!1 &1752959503665396
|
--- !u!1 &1752959503665396
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -620,7 +620,18 @@ MonoBehaviour:
|
||||||
m_TargetGraphic: {fileID: 114026082862082466}
|
m_TargetGraphic: {fileID: 114026082862082466}
|
||||||
m_OnClick:
|
m_OnClick:
|
||||||
m_PersistentCalls:
|
m_PersistentCalls:
|
||||||
m_Calls: []
|
m_Calls:
|
||||||
|
- m_Target: {fileID: 0}
|
||||||
|
m_MethodName: Continue
|
||||||
|
m_Mode: 1
|
||||||
|
m_Arguments:
|
||||||
|
m_ObjectArgument: {fileID: 0}
|
||||||
|
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||||
|
m_IntArgument: 0
|
||||||
|
m_FloatArgument: 0
|
||||||
|
m_StringArgument:
|
||||||
|
m_BoolArgument: 0
|
||||||
|
m_CallState: 2
|
||||||
m_TypeName: UnityEngine.UI.Button+ButtonClickedEvent, UnityEngine.UI, Version=1.0.0.0,
|
m_TypeName: UnityEngine.UI.Button+ButtonClickedEvent, UnityEngine.UI, Version=1.0.0.0,
|
||||||
Culture=neutral, PublicKeyToken=null
|
Culture=neutral, PublicKeyToken=null
|
||||||
--- !u!114 &114060586777901180
|
--- !u!114 &114060586777901180
|
||||||
|
@ -1400,6 +1411,7 @@ MonoBehaviour:
|
||||||
restartUIPanel: {fileID: 1604998495297016}
|
restartUIPanel: {fileID: 1604998495297016}
|
||||||
healthcontroller: {fileID: 114617351635937986}
|
healthcontroller: {fileID: 114617351635937986}
|
||||||
brakeBarController: {fileID: 114745107968250074}
|
brakeBarController: {fileID: 114745107968250074}
|
||||||
|
pausedUIPanel: {fileID: 1139220909146914}
|
||||||
mainMenuSceneIndex: 0
|
mainMenuSceneIndex: 0
|
||||||
--- !u!114 &114930219842054174
|
--- !u!114 &114930219842054174
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
|
@ -1968,7 +1980,7 @@ RectTransform:
|
||||||
m_PrefabParentObject: {fileID: 0}
|
m_PrefabParentObject: {fileID: 0}
|
||||||
m_PrefabInternal: {fileID: 100100000}
|
m_PrefabInternal: {fileID: 100100000}
|
||||||
m_GameObject: {fileID: 1171183456984172}
|
m_GameObject: {fileID: 1171183456984172}
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children:
|
m_Children:
|
||||||
|
|
|
@ -1422,6 +1422,59 @@ Prefab:
|
||||||
propertyPath: m_Pivot.y
|
propertyPath: m_Pivot.y
|
||||||
value: 0
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 224030602021903918, guid: 460d856ea4eb14cedb5fecde1fe6d743,
|
||||||
|
type: 2}
|
||||||
|
propertyPath: m_AnchorMax.x
|
||||||
|
value: 0.7
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 224030602021903918, guid: 460d856ea4eb14cedb5fecde1fe6d743,
|
||||||
|
type: 2}
|
||||||
|
propertyPath: m_AnchorMax.y
|
||||||
|
value: 1
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 224899125652206328, guid: 460d856ea4eb14cedb5fecde1fe6d743,
|
||||||
|
type: 2}
|
||||||
|
propertyPath: m_AnchorMin.x
|
||||||
|
value: 0.7
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 224899125652206328, guid: 460d856ea4eb14cedb5fecde1fe6d743,
|
||||||
|
type: 2}
|
||||||
|
propertyPath: m_AnchorMax.x
|
||||||
|
value: 0.7
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 224899125652206328, guid: 460d856ea4eb14cedb5fecde1fe6d743,
|
||||||
|
type: 2}
|
||||||
|
propertyPath: m_AnchorMax.y
|
||||||
|
value: 1
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1139220909146914, guid: 460d856ea4eb14cedb5fecde1fe6d743, type: 2}
|
||||||
|
propertyPath: m_IsActive
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1738841749900334, guid: 460d856ea4eb14cedb5fecde1fe6d743, type: 2}
|
||||||
|
propertyPath: m_IsActive
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 224646073885350970, guid: 460d856ea4eb14cedb5fecde1fe6d743,
|
||||||
|
type: 2}
|
||||||
|
propertyPath: m_LocalRotation.x
|
||||||
|
value: -0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 224646073885350970, guid: 460d856ea4eb14cedb5fecde1fe6d743,
|
||||||
|
type: 2}
|
||||||
|
propertyPath: m_LocalRotation.y
|
||||||
|
value: -0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 224646073885350970, guid: 460d856ea4eb14cedb5fecde1fe6d743,
|
||||||
|
type: 2}
|
||||||
|
propertyPath: m_LocalRotation.z
|
||||||
|
value: -0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 114917026543374048, guid: 460d856ea4eb14cedb5fecde1fe6d743,
|
||||||
|
type: 2}
|
||||||
|
propertyPath: pausedUIPanel
|
||||||
|
value:
|
||||||
|
objectReference: {fileID: 1379476070}
|
||||||
m_RemovedComponents: []
|
m_RemovedComponents: []
|
||||||
m_ParentPrefab: {fileID: 100100000, guid: 460d856ea4eb14cedb5fecde1fe6d743, type: 2}
|
m_ParentPrefab: {fileID: 100100000, guid: 460d856ea4eb14cedb5fecde1fe6d743, type: 2}
|
||||||
m_IsPrefabParent: 0
|
m_IsPrefabParent: 0
|
||||||
|
@ -1430,6 +1483,11 @@ GameObject:
|
||||||
m_PrefabParentObject: {fileID: 1998375241450644, guid: 460d856ea4eb14cedb5fecde1fe6d743,
|
m_PrefabParentObject: {fileID: 1998375241450644, guid: 460d856ea4eb14cedb5fecde1fe6d743,
|
||||||
type: 2}
|
type: 2}
|
||||||
m_PrefabInternal: {fileID: 1379476068}
|
m_PrefabInternal: {fileID: 1379476068}
|
||||||
|
--- !u!1 &1379476070 stripped
|
||||||
|
GameObject:
|
||||||
|
m_PrefabParentObject: {fileID: 1139220909146914, guid: 460d856ea4eb14cedb5fecde1fe6d743,
|
||||||
|
type: 2}
|
||||||
|
m_PrefabInternal: {fileID: 1379476068}
|
||||||
--- !u!1001 &1543828915
|
--- !u!1001 &1543828915
|
||||||
Prefab:
|
Prefab:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
|
@ -95,15 +95,17 @@ public class GameController : MonoBehaviour {
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private GameObject mapRoot;
|
private GameObject mapRoot;
|
||||||
|
|
||||||
private bool engineInitDone;
|
bool engineInitDone;
|
||||||
private Player player;
|
Player player;
|
||||||
|
|
||||||
|
bool pausedPressed = false;
|
||||||
|
|
||||||
public static GameController instance;
|
public static GameController instance;
|
||||||
public GameController() {
|
public GameController() {
|
||||||
instance = this;
|
instance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum GameState { UNSET, INIT, STARTING, RUNNING, ENDED };
|
public enum GameState { UNSET, INIT, STARTING, PAUSED, RUNNING, ENDED };
|
||||||
private EndedCause endCause = EndedCause.DIED;
|
private EndedCause endCause = EndedCause.DIED;
|
||||||
private GameState state = GameState.UNSET;
|
private GameState state = GameState.UNSET;
|
||||||
|
|
||||||
|
@ -152,6 +154,16 @@ public class GameController : MonoBehaviour {
|
||||||
Debug.Log("First Frame");
|
Debug.Log("First Frame");
|
||||||
ChangeState(GameState.INIT);
|
ChangeState(GameState.INIT);
|
||||||
}
|
}
|
||||||
|
if (Input.GetAxis("Pause") > 0) {
|
||||||
|
if (state == GameState.RUNNING && !pausedPressed) {
|
||||||
|
ChangeState(GameState.PAUSED);
|
||||||
|
} else if (state == GameState.PAUSED && !pausedPressed) {
|
||||||
|
ChangeState(GameState.RUNNING);
|
||||||
|
}
|
||||||
|
pausedPressed = true;
|
||||||
|
} else {
|
||||||
|
pausedPressed = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ChangeState(GameState nextState) {
|
public void ChangeState(GameState nextState) {
|
||||||
|
@ -174,6 +186,9 @@ public class GameController : MonoBehaviour {
|
||||||
case GameState.RUNNING:
|
case GameState.RUNNING:
|
||||||
Running();
|
Running();
|
||||||
break;
|
break;
|
||||||
|
case GameState.PAUSED:
|
||||||
|
Paused();
|
||||||
|
break;
|
||||||
case GameState.ENDED:
|
case GameState.ENDED:
|
||||||
Ended();
|
Ended();
|
||||||
break;
|
break;
|
||||||
|
@ -311,7 +326,9 @@ public class GameController : MonoBehaviour {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Running() {
|
private void Running() {
|
||||||
|
Time.timeScale = 1;
|
||||||
|
player.GetComponent<PlayerMovement>().enabled = true;
|
||||||
|
GetUI().showPauseUI(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Ended() {
|
private void Ended() {
|
||||||
|
@ -354,4 +371,14 @@ public class GameController : MonoBehaviour {
|
||||||
endCause = cause;
|
endCause = cause;
|
||||||
ChangeState(GameState.ENDED);
|
ChangeState(GameState.ENDED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Paused() {
|
||||||
|
Time.timeScale = 0;
|
||||||
|
player.GetComponent<PlayerMovement>().enabled = false;
|
||||||
|
GetUI().showPauseUI(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Continue() {
|
||||||
|
ChangeState(GameState.RUNNING);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,9 @@ public class UIController : MonoBehaviour
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
BrakeBarController brakeBarController;
|
BrakeBarController brakeBarController;
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
GameObject pausedUIPanel;
|
||||||
|
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
int mainMenuSceneIndex = 0;
|
int mainMenuSceneIndex = 0;
|
||||||
int firstSceneIndex = 1;
|
int firstSceneIndex = 1;
|
||||||
|
@ -80,4 +83,12 @@ public class UIController : MonoBehaviour
|
||||||
public NotificationManager GetNotificationManager() {
|
public NotificationManager GetNotificationManager() {
|
||||||
return notifications;
|
return notifications;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void showPauseUI(bool show) {
|
||||||
|
if (pausedUIPanel != null) {
|
||||||
|
pausedUIPanel.SetActive(show);
|
||||||
|
} else {
|
||||||
|
Debug.Log("Paused UI not assigned");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -309,3 +309,19 @@ InputManager:
|
||||||
type: 0
|
type: 0
|
||||||
axis: 0
|
axis: 0
|
||||||
joyNum: 0
|
joyNum: 0
|
||||||
|
- serializedVersion: 3
|
||||||
|
m_Name: Pause
|
||||||
|
descriptiveName:
|
||||||
|
descriptiveNegativeName:
|
||||||
|
negativeButton:
|
||||||
|
positiveButton: escape
|
||||||
|
altNegativeButton:
|
||||||
|
altPositiveButton: p
|
||||||
|
gravity: 1000
|
||||||
|
dead: 0.001
|
||||||
|
sensitivity: 1000
|
||||||
|
snap: 0
|
||||||
|
invert: 0
|
||||||
|
type: 0
|
||||||
|
axis: 0
|
||||||
|
joyNum: 0
|
||||||
|
|
Loading…
Add table
Reference in a new issue