유니티

InputActionPhase

잼잼재미 2024. 1. 11. 13:58

InputActionPhase


  • Started: 실행 시작 시 호출 (버튼 눌렀을 때)
  • Performed: 실행 확정 시 호출 (버튼 눌렀을 때, Started 뒤에 실행)
  • Canceled: 실행 종료 시 호출 ( 버튼 뗐을 때)
  • Disabled: 액션이 활성화되지 않음
  • Waiting: 액션이 활성화되어있고 입력을 기다리는 상태

 

예시


public void OnMoveInput(InputAction.CallbackContext context)
{
    if (context.phase == InputActionPhase.Performed)	// 버튼 눌렀을 때
    {
        _curMovementInput = context.ReadValue<Vector2>();
    }
    else if (context.phase == InputActionPhase.Canceled)	// 버튼 뗐을 때
    {
        _curMovementInput = Vector2.zero;
    }
}