Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question InputActionPhase bug?

Discussion in 'Input System' started by sinyeah_hema, Dec 28, 2022.

  1. sinyeah_hema

    sinyeah_hema

    Joined:
    Oct 16, 2019
    Posts:
    2
    I'm So confused. When I get InputActionPhase in CallbackContext, I can get all the states(Started,Performed,Canceled),But when I get it in Update, it will aways be 'Started'. 截屏2022-12-28 15.56.21.png
    By this way the 'phase' is expected:
    Code (CSharp):
    1. protected override void OnCreate() {
    2.             gameInputControls = new GameInputControls();
    3.             cameraActions = gameInputControls.Camera;
    4.             moveByPointerDrag = cameraActions.MoveByPointerDrag;
    5.            
    6.             moveByPointerDrag.started += OnMoveByPointerDrag;
    7.             moveByPointerDrag.performed += OnMoveByPointerDrag;
    8.             moveByPointerDrag.canceled += OnMoveByPointerDrag;
    9.         }
    Code (CSharp):
    1. private void OnMoveByPointerDrag(InputAction.CallbackContext context) {
    2.             Debug.Log($"context.phase : {context.phase}");
    3.         }
    截屏2022-12-28 16.04.41.png
    And if I get It in this way, It aways be 'Started'
    Code (CSharp):
    1. protected override void OnUpdate() {
    2.             if(moveByPointerDrag.phase != InputActionPhase.Waiting)
    3.                 Debug.Log($"moveByPointerDrag.phase : {moveByPointerDrag.phase}");
    4.         }
    截屏2022-12-28 16.07.58.png

    How can I get all the states(Started,Performed,Canceled) in OnUpdate?
     
  2. sinyeah_hema

    sinyeah_hema

    Joined:
    Oct 16, 2019
    Posts:
    2
    OK, I have found an other way that finish my work.