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 IBeginDragHandler not called when cursor is locked

Discussion in 'Input System' started by tjmaul, Jan 29, 2023.

  1. tjmaul

    tjmaul

    Joined:
    Aug 29, 2018
    Posts:
    464
    Hi there,

    I just switched to the (new) InputSystem and I really like it so far! I experimented with the EventSystem to receive IPointerEnter and IPointerExit events by replacing the StandaloneInputModule with https://docs.unity3d.com/Packages/c....InputSystem.UI.InputSystemUIInputModule.html

    For first person controllers (where the cursor is obviously locked in the center of the screen), this unfortunately only works with the aforementioned events but not with IBeginDragHandler (and Drag and EndDrag). Inspecting the InputSystemUIInputModule code i can see that it checks if the cursor is not locked and if the mouse has moved a certain distance, both of which probably false in the case of first person controllers.

    is there any feasible way to make this happen? I understand that the concept of a certain moved pixel distance to trigger the onbegindrag is not applicable in 3D space, but I’d be happy with ignoring this number to receive those events.
     
  2. Moarqi

    Moarqi

    Joined:
    May 26, 2021
    Posts:
    1
    Hi tjmaul,

    I just stumbled across the same thing.
    The
    StandaloneInputModule
    uses the same logic as the
    PointerInputModule
    as well as the
    InputSystemUIInputModule
    which I was using. Seems like all of these Modules skip the drag handling for the locked cursor mode like below:

    Code (CSharp):
    1. protected virtual void ProcessDrag(PointerEventData pointerEvent)
    2. {
    3.     if (!pointerEvent.IsPointerMoving() ||
    4.         Cursor.lockState == CursorLockMode.Locked ||
    5.         pointerEvent.pointerDrag == null)
    6.         return;
    7.  
    8.     ...
    9.    
    10. }

    A similar Issue was opened and resolved for the mouseDelta in locked cursor mode
    https://issuetracker.unity3d.com/is...ge-when-the-cursor-lockstate-is-set-to-locked

    I fear for now it's either fork the InputSystem module or open an issue and wait..
     
    tjmaul likes this.