Skip to content
This repository has been archived by the owner on Mar 8, 2019. It is now read-only.

Commit

Permalink
Added keyboard controls to menus
Browse files Browse the repository at this point in the history
  • Loading branch information
LoshkinOleg committed Mar 5, 2019
1 parent 3292e2c commit b6957e0
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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.
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Button>().onClick.Invoke();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ private void Start()

private void Update()
{
if (InputManager.ActiveDevice.AnyButtonWasPressed)
if (InputManager.ActiveDevice.AnyButtonWasPressed || Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.Space))
{
eventSystem.currentSelectedGameObject.GetComponent<Button>().onClick.Invoke();
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,14 @@ PlayerSettings:
banner: {fileID: 0}
androidGamepadSupportLevel: 0
resolutionDialogBanner: {fileID: 0}
m_BuildTargetIcons: []
m_BuildTargetIcons:
- m_BuildTarget:
m_Icons:
- serializedVersion: 2
m_Icon: {fileID: 2800000, guid: 5aec515340a62664290933907f86d50f, type: 3}
m_Width: 128
m_Height: 128
m_Kind: 0
m_BuildTargetPlatformIcons: []
m_BuildTargetBatching: []
m_BuildTargetGraphicsAPIs: []
Expand Down

0 comments on commit b6957e0

Please sign in to comment.