// CoRoutine that expects a joystick input to be pressed IEnumerator waitForInput(int playerNum) { // Disable while waiting p1JoyButton.interactable = false; p2JoyButton.interactable = false; MainInfo.text = "PRESS A BUTTON TO SET PLAYER" + playerNum + " CONTROLLER"; // Wait for input int joyNumPressed = JoystickResources.identifyJoyNumAnyButton(); while (joyNumPressed == -1) { joyNumPressed = JoystickResources.identifyJoyNumAnyButton(); yield return(null); } // Enable p1JoyButton.interactable = true; p2JoyButton.interactable = true; MainInfo.text = "CONTROLLER DEBUG"; if (playerNum == 1) { this.p1Joynum = joyNumPressed; } else if (playerNum == 2) { this.p2Joynum = joyNumPressed; } else { Debug.Log("Wrong player number used at waitForInput coroutine"); } }
public void updateP2Info() { string text = "Joystick Num: "; if (p2Joynum == -1) { text += "NONE"; } else { text += p2Joynum + "\nKey is being pressed: " + JoystickResources.anyButtonDown(p2Joynum); } p2JoyInfo.text = text; }