- Home /
Disabling view of mouse outside of Unity window
Hello, do you know if it is possible for the mouse to be hidden while playing a Unity game even when it's outside of the game window?
Answer by Bunny83 · Jun 25, 2012 at 11:34 AM
You actually want to use Screen.lockCursor then. If you set showCursor to false it will only affect the visibility on the Unity window. When the cursor is outside of the game window and the user clicks, your game will loose the focus, so it makes no sense to "hide" it outside of the game window.
You want to lock the cursor so it can't leave the gamewindow. However that will freeze the cursor at the windows center. If you need a mouse cursor inside your gamewindow, you can display a GUITexture as cursor and use the mouse delta to move it:
var xDelta = Input.GetAxis ("Mouse X");
var yDelta = Input.GetAxis ("Mouse Y");
AdamV, if its correct then please mark it as an answer, so that it will be easy for others. Thanks :)
Answer by BeHappy · Jun 25, 2012 at 11:36 AM
I guess you could not handle the cursor outside the game window through unity....
You can hide it only inside Unity game window.
Have a look at, Locking the cursor - Screen-lockCursor