textures and pause game

This commit is contained in:
ntr committed 2023-10-03 16:37:17 +11:00
1 parent 8a0162cf9d
commit 8472073b56
11 files changed
+43 -23

No files matched your search

+17 -2
View File
@@ -29,7 +29,7 @@ public class MenuControls : MonoBehaviour {
ControlsUI controlsUI;
[SerializeField]
ShipAudio audio;
ShipAudio shipAudio;
SpaceRaceInput input;
@@ -68,14 +68,26 @@ public class MenuControls : MonoBehaviour {
input.menu.Enable();
input.menu.ToggleMenu.started += OnToggleMenu;
input.menu.CloseMenu.started += OnCloseMenu;
InputSystem.onDeviceChange += OnDeviceChange;
}
void OnDeviceChange(InputDevice device, InputDeviceChange change) {
if (change != InputDeviceChange.Removed) return;
Show();
}
void OnDestroy() {
input.menu.ToggleMenu.started -= OnToggleMenu;
input.menu.CloseMenu.started -= OnCloseMenu;
InputSystem.onDeviceChange -= OnDeviceChange;
}
void Show() {
// pause the game
Time.timeScale = 0f;
visible = true;
UnityEngine.Cursor.lockState = CursorLockMode.None;
menuDoc.enabled = true;
@@ -96,6 +108,9 @@ public class MenuControls : MonoBehaviour {
}
void Hide() {
// pause the game
Time.timeScale = 1f;
visible = false;
UnityEngine.Cursor.lockState = CursorLockMode.Locked;
menuDoc.enabled = false;
@@ -111,7 +126,7 @@ public class MenuControls : MonoBehaviour {
}
void OnToggleMenu(InputAction.CallbackContext _ctx) {
audio.PlayNoise();
shipAudio.PlayNoise();
visible = !visible;
if (visible) {