From b6957e0ff47b2a723146f003617bc2266b65839f Mon Sep 17 00:00:00 2001 From: Oleg Date: Tue, 5 Mar 2019 15:01:44 +0100 Subject: [PATCH] Added keyboard controls to menus --- .../Scripts/UI/MainMenuGamepadController.cs | 6 +- .../Scripts/UI/PauseMenuController.cs | 6 +- .../Scripts/UI/ScoreMenuGamepadController.cs | 2 +- .../Assets/ParatroopersFiles/Sprites/icon.png | Bin 0 -> 27754 bytes .../ParatroopersFiles/Sprites/icon.png.meta | 121 ++++++++++++++++++ .../ProjectSettings/ProjectSettings.asset | 9 +- 6 files changed, 136 insertions(+), 8 deletions(-) create mode 100644 TheParatroopersUnityProject/Assets/ParatroopersFiles/Sprites/icon.png create mode 100644 TheParatroopersUnityProject/Assets/ParatroopersFiles/Sprites/icon.png.meta diff --git a/TheParatroopersUnityProject/Assets/ParatroopersFiles/Scripts/UI/MainMenuGamepadController.cs b/TheParatroopersUnityProject/Assets/ParatroopersFiles/Scripts/UI/MainMenuGamepadController.cs index 38b2846..ebbd63d 100644 --- a/TheParatroopersUnityProject/Assets/ParatroopersFiles/Scripts/UI/MainMenuGamepadController.cs +++ b/TheParatroopersUnityProject/Assets/ParatroopersFiles/Scripts/UI/MainMenuGamepadController.cs @@ -21,11 +21,11 @@ private void Update() if (!creditsAreOpen && !howToPlayIsOpen) // If we're in main menu. { // If we're selecting a button. - if (InputManager.ActiveDevice.LeftStick.Up.WasPressed || InputManager.ActiveDevice.RightStick.Up.WasPressed || InputManager.ActiveDevice.DPadUp.WasPressed) + if (InputManager.ActiveDevice.LeftStick.Up.WasPressed || InputManager.ActiveDevice.RightStick.Up.WasPressed || InputManager.ActiveDevice.DPadUp.WasPressed || Input.GetKeyDown(KeyCode.UpArrow) || Input.GetKeyDown(KeyCode.W)) { mainMenuSelectedButton = mainMenuSelectedButton - 1 <= 0 ? 0 : mainMenuSelectedButton - 1; } - else if (InputManager.ActiveDevice.LeftStick.Down.WasPressed || InputManager.ActiveDevice.RightStick.Down.WasPressed || InputManager.ActiveDevice.DPadDown.WasPressed) + else if (InputManager.ActiveDevice.LeftStick.Down.WasPressed || InputManager.ActiveDevice.RightStick.Down.WasPressed || InputManager.ActiveDevice.DPadDown.WasPressed || Input.GetKeyDown(KeyCode.DownArrow) || Input.GetKeyDown(KeyCode.S)) { mainMenuSelectedButton = mainMenuSelectedButton + 1 >= 3 ? 3 : mainMenuSelectedButton + 1; } @@ -41,7 +41,7 @@ private void Update() } // If there was a submit input. - if (InputManager.ActiveDevice.Action1.WasPressed || InputManager.ActiveDevice.Action2.WasPressed || InputManager.ActiveDevice.Action3.WasPressed || InputManager.ActiveDevice.Action4.WasPressed) + if (InputManager.ActiveDevice.AnyButtonWasPressed || Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.Space)) { if (!creditsAreOpen && !howToPlayIsOpen) // If we're in main menu. { diff --git a/TheParatroopersUnityProject/Assets/ParatroopersFiles/Scripts/UI/PauseMenuController.cs b/TheParatroopersUnityProject/Assets/ParatroopersFiles/Scripts/UI/PauseMenuController.cs index 52fa568..83dba28 100644 --- a/TheParatroopersUnityProject/Assets/ParatroopersFiles/Scripts/UI/PauseMenuController.cs +++ b/TheParatroopersUnityProject/Assets/ParatroopersFiles/Scripts/UI/PauseMenuController.cs @@ -15,17 +15,17 @@ private void Update() { if (GameManager.Instance.IsPaused) { - if (InputManager.ActiveDevice.LeftStick.Up.WasPressed || InputManager.ActiveDevice.RightStick.Up.WasPressed || InputManager.ActiveDevice.DPadUp.WasPressed) + if (InputManager.ActiveDevice.LeftStick.Up.WasPressed || InputManager.ActiveDevice.RightStick.Up.WasPressed || InputManager.ActiveDevice.DPadUp.WasPressed || Input.GetKeyDown(KeyCode.UpArrow) || Input.GetKeyDown(KeyCode.W)) { selectedButton = selectedButton - 1 <= 0 ? 0 : selectedButton - 1; } - else if (InputManager.ActiveDevice.LeftStick.Down.WasPressed || InputManager.ActiveDevice.RightStick.Down.WasPressed || InputManager.ActiveDevice.DPadDown.WasPressed) + else if (InputManager.ActiveDevice.LeftStick.Down.WasPressed || InputManager.ActiveDevice.RightStick.Down.WasPressed || InputManager.ActiveDevice.DPadDown.WasPressed || Input.GetKeyDown(KeyCode.DownArrow) || Input.GetKeyDown(KeyCode.S)) { selectedButton = selectedButton + 1 >= 1 ? 1 : selectedButton + 1; } level1_eventSystem.SetSelectedGameObject(buttons[selectedButton]); - if (InputManager.ActiveDevice.Action1.WasPressed || InputManager.ActiveDevice.Action2.WasPressed || InputManager.ActiveDevice.Action3.WasPressed || InputManager.ActiveDevice.Action4.WasPressed) + if (InputManager.ActiveDevice.AnyButtonWasPressed || Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.Space)) { level1_eventSystem.currentSelectedGameObject.GetComponent