Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Feature Request Cursor.Locked Mode Drag Handlers

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

  1. tjmaul

    tjmaul

    Joined:
    Aug 29, 2018
    Posts:
    467
    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
    InputSystemUIInputModule.cs
    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:

    https://github.com/Unity-Technologies/InputSystem/compare/develop...fi4sk0:InputSystem:develop

    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