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. Dismiss Notice

Question Why is "_dragging.started += DraggingStarted;" called every frame?

Discussion in 'Input System' started by SteenPetersen, Aug 6, 2022.

  1. SteenPetersen

    SteenPetersen

    Joined:
    Mar 13, 2016
    Posts:
    78
    Code (CSharp):
    1. [SerializeField] private InputAction _dragging;
    2.  
    3. private void OnEnable()
    4.     {
    5.         _dragging.started += DraggingStarted;
    6.         _dragging.performed += Drag;
    7.         _dragging.canceled += DragCancelled;
    8.     }
    9.  
    10.     private void DraggingStarted(InputAction.CallbackContext obj)
    11.     {
    12.         Debug.Log("Drag started");
    13.     }
    14.  
    15.     private void OnDisable()
    16.     {    
    17.         _dragging.started -= DraggingStarted;
    18.         _dragging.performed -= Drag;
    19.         _dragging.canceled -= DragCancelled;
    20.     }
    Trying to wrap my head around the new input system. What is the point of the drag.started if it is called every frame?

    upload_2022-8-6_16-35-40.png

    Am I missing something?