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

Question 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:
    247
    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,035
    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:
    247
    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.