- Home /
Cursor.lockState = CursorLockMode.None; wont work in build
This code is used when I change scenes it works perfect in the editor but in the build, it stays locked how do I fix this?
Answer by goddatr · May 09, 2018 at 02:45 PM
The editor allows to escape the mouse to change things in the scene no matter what your code said. So I guess your mouse cursor is unlocked but still invisible. Cursor.lockState
doesn't change the visibility of the cursor. Try adding Cursor.visible = true;
after your lockState change. and the cursor should be visible and unlocked in your build too.
I do have the Cursor.visible = true; in my code. before I put Cursor.lockState = CursorLock$$anonymous$$ode.none; in my script the mouse would be locked in the editor as well. I'm using the default fps controller in the previous scene and the mouse is locked there unless i press esc.this link; https://forum.unity.com/threads/cursor-lockstate-troubles.278221/ talkes about this being a well known bug, but this is 3-4 years ago
I am not using the most recent version of unity I haven't updated it for a month or so. I'll check the version when I have a chance
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
SetCursor WebGL doesn't work 1 Answer
Cursor not locking in center of screen? 1 Answer
Mouse cursor is giant in Mac builds. 1 Answer
CursorLockMode.Locked puts cursor above actual center 0 Answers