Skip to content

Commit 2bfe7a5

Browse files
committed
feat(Game): Esc key exits game
1 parent 8efd1cc commit 2bfe7a5

File tree

7 files changed

+1035
-1433
lines changed

7 files changed

+1035
-1433
lines changed

Assets/MainScene.unity

+909-1,432
Large diffs are not rendered by default.

Assets/Scripts/Global/GameLoop.cs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using UnityEngine;
2+
using UnityEngine.SceneManagement;
3+
4+
public class GameLoop : MonoBehaviour
5+
{
6+
private void Start()
7+
{
8+
var kbmInput = new PlayerInputAction().KBMPlayer;
9+
kbmInput.Enable();
10+
//kbmInput.Reset.performed += _ => SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
11+
kbmInput.Exit.performed += _ => Application.Quit();
12+
}
13+
}

Assets/Scripts/Global/GameLoop.cs.meta

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Scripts/Player/KBMPlayer.cs

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
namespace PerceptionVR.Player
88
{
9-
[RequireComponent(typeof(TeleportableJoint))]
109
public class KBMPlayer : PlayerBase
1110
{
1211
[Range(0, 10)]

Assets/Scripts/Player/PlayerInputAction.cs

+60
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,24 @@ public @PlayerInputAction()
8080
""processors"": """",
8181
""interactions"": """",
8282
""initialStateCheck"": true
83+
},
84+
{
85+
""name"": ""Exit"",
86+
""type"": ""Button"",
87+
""id"": ""7243590f-53e4-4176-949d-3ea66b4ac43a"",
88+
""expectedControlType"": ""Button"",
89+
""processors"": """",
90+
""interactions"": """",
91+
""initialStateCheck"": false
92+
},
93+
{
94+
""name"": ""Reset"",
95+
""type"": ""Button"",
96+
""id"": ""2af38dcd-2b9f-4644-a43c-e1d24354f02c"",
97+
""expectedControlType"": ""Button"",
98+
""processors"": """",
99+
""interactions"": """",
100+
""initialStateCheck"": false
83101
}
84102
],
85103
""bindings"": [
@@ -214,6 +232,28 @@ public @PlayerInputAction()
214232
""action"": ""Grab"",
215233
""isComposite"": false,
216234
""isPartOfComposite"": false
235+
},
236+
{
237+
""name"": """",
238+
""id"": ""76f1dd18-91d8-4a4b-a516-f4a6736cb00f"",
239+
""path"": ""<Keyboard>/escape"",
240+
""interactions"": """",
241+
""processors"": """",
242+
""groups"": """",
243+
""action"": ""Exit"",
244+
""isComposite"": false,
245+
""isPartOfComposite"": false
246+
},
247+
{
248+
""name"": """",
249+
""id"": ""35e89958-fa07-414c-8329-d63ff74ac3f9"",
250+
""path"": ""<Keyboard>/r"",
251+
""interactions"": """",
252+
""processors"": """",
253+
""groups"": """",
254+
""action"": ""Reset"",
255+
""isComposite"": false,
256+
""isPartOfComposite"": false
217257
}
218258
]
219259
},
@@ -574,6 +614,8 @@ public @PlayerInputAction()
574614
m_KBMPlayer_Walk = m_KBMPlayer.FindAction("Walk", throwIfNotFound: true);
575615
m_KBMPlayer_ControlBlock = m_KBMPlayer.FindAction("ControlBlock", throwIfNotFound: true);
576616
m_KBMPlayer_Grab = m_KBMPlayer.FindAction("Grab", throwIfNotFound: true);
617+
m_KBMPlayer_Exit = m_KBMPlayer.FindAction("Exit", throwIfNotFound: true);
618+
m_KBMPlayer_Reset = m_KBMPlayer.FindAction("Reset", throwIfNotFound: true);
577619
// VRPlayer
578620
m_VRPlayer = asset.FindActionMap("VRPlayer", throwIfNotFound: true);
579621
m_VRPlayer_LeftControllerPosition = m_VRPlayer.FindAction("LeftControllerPosition", throwIfNotFound: true);
@@ -656,6 +698,8 @@ public int FindBinding(InputBinding bindingMask, out InputAction action)
656698
private readonly InputAction m_KBMPlayer_Walk;
657699
private readonly InputAction m_KBMPlayer_ControlBlock;
658700
private readonly InputAction m_KBMPlayer_Grab;
701+
private readonly InputAction m_KBMPlayer_Exit;
702+
private readonly InputAction m_KBMPlayer_Reset;
659703
public struct KBMPlayerActions
660704
{
661705
private @PlayerInputAction m_Wrapper;
@@ -666,6 +710,8 @@ public struct KBMPlayerActions
666710
public InputAction @Walk => m_Wrapper.m_KBMPlayer_Walk;
667711
public InputAction @ControlBlock => m_Wrapper.m_KBMPlayer_ControlBlock;
668712
public InputAction @Grab => m_Wrapper.m_KBMPlayer_Grab;
713+
public InputAction @Exit => m_Wrapper.m_KBMPlayer_Exit;
714+
public InputAction @Reset => m_Wrapper.m_KBMPlayer_Reset;
669715
public InputActionMap Get() { return m_Wrapper.m_KBMPlayer; }
670716
public void Enable() { Get().Enable(); }
671717
public void Disable() { Get().Disable(); }
@@ -693,6 +739,12 @@ public void SetCallbacks(IKBMPlayerActions instance)
693739
@Grab.started -= m_Wrapper.m_KBMPlayerActionsCallbackInterface.OnGrab;
694740
@Grab.performed -= m_Wrapper.m_KBMPlayerActionsCallbackInterface.OnGrab;
695741
@Grab.canceled -= m_Wrapper.m_KBMPlayerActionsCallbackInterface.OnGrab;
742+
@Exit.started -= m_Wrapper.m_KBMPlayerActionsCallbackInterface.OnExit;
743+
@Exit.performed -= m_Wrapper.m_KBMPlayerActionsCallbackInterface.OnExit;
744+
@Exit.canceled -= m_Wrapper.m_KBMPlayerActionsCallbackInterface.OnExit;
745+
@Reset.started -= m_Wrapper.m_KBMPlayerActionsCallbackInterface.OnReset;
746+
@Reset.performed -= m_Wrapper.m_KBMPlayerActionsCallbackInterface.OnReset;
747+
@Reset.canceled -= m_Wrapper.m_KBMPlayerActionsCallbackInterface.OnReset;
696748
}
697749
m_Wrapper.m_KBMPlayerActionsCallbackInterface = instance;
698750
if (instance != null)
@@ -715,6 +767,12 @@ public void SetCallbacks(IKBMPlayerActions instance)
715767
@Grab.started += instance.OnGrab;
716768
@Grab.performed += instance.OnGrab;
717769
@Grab.canceled += instance.OnGrab;
770+
@Exit.started += instance.OnExit;
771+
@Exit.performed += instance.OnExit;
772+
@Exit.canceled += instance.OnExit;
773+
@Reset.started += instance.OnReset;
774+
@Reset.performed += instance.OnReset;
775+
@Reset.canceled += instance.OnReset;
718776
}
719777
}
720778
}
@@ -890,6 +948,8 @@ public interface IKBMPlayerActions
890948
void OnWalk(InputAction.CallbackContext context);
891949
void OnControlBlock(InputAction.CallbackContext context);
892950
void OnGrab(InputAction.CallbackContext context);
951+
void OnExit(InputAction.CallbackContext context);
952+
void OnReset(InputAction.CallbackContext context);
893953
}
894954
public interface IVRPlayerActions
895955
{

Assets/Scripts/Player/PlayerInputAction.inputactions

+40
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,24 @@
5858
"processors": "",
5959
"interactions": "",
6060
"initialStateCheck": true
61+
},
62+
{
63+
"name": "Exit",
64+
"type": "Button",
65+
"id": "7243590f-53e4-4176-949d-3ea66b4ac43a",
66+
"expectedControlType": "Button",
67+
"processors": "",
68+
"interactions": "",
69+
"initialStateCheck": false
70+
},
71+
{
72+
"name": "Reset",
73+
"type": "Button",
74+
"id": "2af38dcd-2b9f-4644-a43c-e1d24354f02c",
75+
"expectedControlType": "Button",
76+
"processors": "",
77+
"interactions": "",
78+
"initialStateCheck": false
6179
}
6280
],
6381
"bindings": [
@@ -192,6 +210,28 @@
192210
"action": "Grab",
193211
"isComposite": false,
194212
"isPartOfComposite": false
213+
},
214+
{
215+
"name": "",
216+
"id": "76f1dd18-91d8-4a4b-a516-f4a6736cb00f",
217+
"path": "<Keyboard>/escape",
218+
"interactions": "",
219+
"processors": "",
220+
"groups": "",
221+
"action": "Exit",
222+
"isComposite": false,
223+
"isPartOfComposite": false
224+
},
225+
{
226+
"name": "",
227+
"id": "35e89958-fa07-414c-8329-d63ff74ac3f9",
228+
"path": "<Keyboard>/r",
229+
"interactions": "",
230+
"processors": "",
231+
"groups": "",
232+
"action": "Reset",
233+
"isComposite": false,
234+
"isPartOfComposite": false
195235
}
196236
]
197237
},

ProjectSettings/ProjectSettings.asset

+2
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ PlayerSettings:
137137
bundleVersion: 0.0.1
138138
preloadedAssets:
139139
- {fileID: 11400000, guid: f4f737390e857f8428b5fc978ee6b991, type: 2}
140+
- {fileID: 8580968305912984312, guid: da8c2284344b57946a6e00f1a4c18f38, type: 2}
141+
- {fileID: -6994848201739095642, guid: 6a5bb00a6a9f4f7478d1f5ede8d88029, type: 2}
140142
metroInputSource: 0
141143
wsaTransparentSwapchain: 0
142144
m_HolographicPauseOnTrackingLoss: 1

0 commit comments

Comments
 (0)