unity menu controller code code example
Example: unity menu controller code
int VerticalInput = (int)Input.GetAxis("Vertical");
if (!MenuActive && Input.anyKeyDown)
TurnOnMenu();
else if (MenuActive && Input.GetButtonDown("B"))
TurnOnTitle();
if (MenuActive)
{
if (VerticalInput != 0)
{
StartCoroutine(MenuChange(VerticalInput));
}
MainMenu[Selected].GetComponent<Button>().Select();
}
}
IEnumerator MenuChange(int input)
{
if (input < 0 && Selected < MainMenu.Length - 1)
Selected++;
else if (input > 0 && Selected > 0)
Selected--;
yield return new WaitForSeconds(1f);
StopCoroutine(MenuChange(0));
}