Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Help Wanted Locking the cursor in the middle of the screen but visible

Discussion in 'Scripting' started by SimRuJ, Jul 30, 2020.

  1. SimRuJ

    SimRuJ

    Joined:
    Apr 7, 2016
    Posts:
    152
    I'm working on a small Unity 2020.1/C# app that lets you walk and look around a room but also click on specific objects to get more information about them. For the "looking around" part I lock the cursor with:

    Cursor.lockState = CursorLockMode.Locked;


    This also automatically hides the cursor and
    Cursor.visible = true
    doesn't affect it (documentation).

    I'm still able to click on objects like that but it's not that easy, especially with small objects, when you can't see the cursor.

    How do I set it to be visible, while still being locked in the middle of the screen?
     
    Last edited: Jul 30, 2020
  2. WarmedxMints

    WarmedxMints

    Joined:
    Feb 6, 2017
    Posts:
    1,017
    Why not just use your own crosshair or point? Just enable a screen overlay canvas that has a dot or something in the middle in those cases.
     
    SimRuJ likes this.
  3. SimRuJ

    SimRuJ

    Joined:
    Apr 7, 2016
    Posts:
    152
    I was actually going to do that if it's absolutely not possible to display the cursor while it's locked but I'm still wondering if there's a way to do it.
     
unityunity