- Home /
Unable Escape Key to Unlock cursor
When the 'ESC' is press, Unity automatically Unlock the cursor. Is a way to change if cursor is lock or unlock only in script? Simple Question.
Answer by StuwuStudio · Mar 03, 2016 at 12:58 PM
Some of you help me but i found a fact which is useful to know about pressing the Escape Key, Unity UnLock the cursor after pressing the Escape Key. What it mean: GetKeyDown cant't lock the cursor because Unity will unlock it after. I tried to Update for checking if the cursor is unlock and no GUI or UI are open. Sorry for bad english...
Answer by Hemaolle · Jun 14, 2016 at 05:07 PM
From the scripting reference
In the Web Player and Editor the cursor will automatically be reset when you press escape. In the Standalone Player you have full control over the mouse cursor, thus it won't automatically be reset unless you switch applications.
So if making a standalone build, it isn't something to be concerned about, and in a web player build it's probably a good thing that the user can free the mouse by pressing esc.
Just for general interest I tested if it's possible to override Unity's behaviour by say, locking the mouse on the next frame but it seemed to me that at least in Unity Editor the mouse could not be locked again before the user had clicked inside the game window again.
Your answer
Follow this Question
Related Questions
Rest of project ignoring script 0 Answers
Mouse cursor doesn't lock Unity 5 0 Answers
Unity5 "MenuItem" not work under build-in menu 0 Answers
Locking the mouse cursor when orbiting camera in Unity Editor 0 Answers
How can I get Unity to automatically import a package when create new project? 0 Answers