void Update() { // update the state based on the change since the last frame // update the state when the button is pressed if (pressedDown) { if (pressedLastFrame) { // was pressed in the previous frame and is still pressed, so the button is considered held CurrentState = InputManager.ButtonState.Held; } else { // button not pressed last frame, but is now, so the button has been pressed down on this frame CurrentState = InputManager.ButtonState.PressedDown; } } else { // now update if the button is not pressed if (pressedLastFrame) { // was pressed last frame, but no longer pressed, so it was released CurrentState = InputManager.ButtonState.Released; } else { // was not pressed last frame and still not pressed, so nothing CurrentState = InputManager.ButtonState.None; } } }
private void Update() { if (pressedDown) { if (pressedLastFrame) { CurrentState = InputManager.ButtonState.Held; } else { CurrentState = InputManager.ButtonState.PressedDown; } } else if (pressedLastFrame) { CurrentState = InputManager.ButtonState.Released; } else { CurrentState = InputManager.ButtonState.None; } }