// Update is called once per frame void Update() { if (gameObject.activeSelf && pauseMenuScript.WaitingOnAnyKeypress && pauseMenuScript.CurrentControl != string.Empty) { // We're decrementing here, so we'll match Joystick#Button# before JoystickButton#. for (KeyCode i = maxKeyCode; i >= minKeyCode; i--) { if (Input.GetKeyDown(i)) { if (pauseMenuScript.AddBinding(pauseMenuScript.CurrentControl, i)) { gameObject.SetActive(false); return; } } } } }