Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Feature Request Cursor.Locked Mode Drag Handlers

Discussion in 'Input System' started by tjmaul, May 9, 2023.

  1. tjmaul


    Aug 29, 2018
    Hi there,

    I have a lot of interactions in my first person game and I would like to use the Input System to have a general solution for selected and dragged objects. All these things work perfectly (IBeginDragHandler, IDragHandler, IEndDragHandler..) when having a mouse pointer in the scene, but don't work when
    Cursor.lockState = CursorLockMode.Locked

    To be more accurate: When I set
    CursorLockBehavior = Screen Center
    , Click events actually work and I can interact with buttons, but dragging sliders doesn't work. I looked at the source code of
    and found some places where the CursorLockMode is explicitly checked and some functions return early.

    I added a property called m_FPSMode to the InputSystemUIInputModule and I'm just skipping those checks. My changes can be found here in a forked version of the InputSystem:

    I'm pretty sure there are better ways to do this, and I feel I butchered the code, but it shows what can be achieved. Here's a video of how this looks ingame.

    Obviously I wouldn't like to both maintain a separate fork of the input system just for that and I hope this might also be useful for other people. Might this be a valid feature request?

    Thanks for reading!
    Last edited: May 9, 2023