x


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?

more ▼

asked Jun 25 '12 at 08:49 AM

AdamV gravatar image

AdamV
1 4 5 5

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

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");
more ▼

answered Jun 25 '12 at 11:34 AM

Bunny83 gravatar image

Bunny83
46.9k 12 50 210

Thank you, that's perfect.

Jun 25 '12 at 08:57 PM AdamV

AdamV, if its correct then please mark it as an answer, so that it will be easy for others. Thanks :)

Jun 26 '12 at 03:17 AM BeHappy
(comments are locked)
10|3000 characters needed characters left

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

more ▼

answered Jun 25 '12 at 11:36 AM

BeHappy gravatar image

BeHappy
238 15 24 31

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1001
x14

asked: Jun 25 '12 at 08:49 AM

Seen: 738 times

Last Updated: Jun 26 '12 at 03:17 AM