void UpdateAxisState(int axis, int desiredValue, ref InputAxisState state) { if (axis == desiredValue) { if (state == InputAxisState.Idle) { state = InputAxisState.Pressed; } else if (state == InputAxisState.Pressed) { state = InputAxisState.Holding; } } else { if (state == InputAxisState.Pressed || state == InputAxisState.Holding) { state = InputAxisState.Released; } else if (state == InputAxisState.Released) { state = InputAxisState.Idle; } } }
void Start() { _shouldUpdate = true; _isUpPressed = InputAxisState.Idle; _isDownPressed = InputAxisState.Idle; _isLeftPressed = InputAxisState.Idle; _isRightPressed = InputAxisState.Idle; }
void UpdateAxisState(int axis, ref InputAxisState positiveState, ref InputAxisState negativeState) { UpdateAxisState(axis, 1, ref positiveState); UpdateAxisState(axis, -1, ref negativeState); }