Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

locking the mouse

Discussion in 'Unity 5 Pre-order Beta' started by BigB, Jan 30, 2015.

  1. BigB

    BigB

    Joined:
    Oct 16, 2008
    Posts:
    672
    Hey guys,

    I'm unable to get this functions to work :

    Cursor.lockState = CursorLockMode.Locked;
    Cursor.lockState = CursorLockMode.None;

    Sometimes they work, other times they don't.
    I'm on B18, now downloading B21 to see if this is fixed.

    Anyone has a workaround for this ? (centering the mouse cursor in the center of the screen).

    Thanks,
    Bruno
     
  2. BigB

    BigB

    Joined:
    Oct 16, 2008
    Posts:
    672
    Problem persists in B21...
     
  3. Tomza

    Tomza

    Joined:
    Aug 27, 2013
    Posts:
    596
    I noticed the same, so I was forced to come back to the old code. The old stuff works great though it's obsolete.
     
  4. BigB

    BigB

    Joined:
    Oct 16, 2008
    Posts:
    672
    You mean you went back to Unity 4.x ?
     
  5. Tomza

    Tomza

    Joined:
    Aug 27, 2013
    Posts:
    596
    No, just use:

    Screen.lockCursor = false;

    and

    Screen.lockCursor = true;

    etc.

    It's obsolete now but at least still works.
     
  6. BigB

    BigB

    Joined:
    Oct 16, 2008
    Posts:
    672
    Screen.lockCursor Doesn't work here either, I had already tested B18 and B21
     
  7. GixG17

    GixG17

    Joined:
    Aug 18, 2013
    Posts:
    105
    To my understanding, lockCursor works if you compile your build for Mac but it won't work for Windows for some reason.