x


Set cursor position

How can i set mouse cursor position?

more ▼

asked Dec 24 '09 at 08:47 AM

Ilja Grach gravatar image

Ilja Grach
93 1 1 10

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

3 answers: sort oldest

in mono you can use the system.windows.form.cursor.position but it needs the windows.form.dll and you need to add this assembly to your project. for mouse clicks you should use external APIs witch are in user32.dll but i don't know anything about OSX. in web players you can use javascript to do mouse movement and click.

note: you can not use external native code in web players.

more ▼

answered Dec 24 '09 at 01:42 PM

Ashkan_gc gravatar image

Ashkan_gc
9.1k 33 56 117

how do you add this assembly to your project? I referenced it in mono, but it keeps dereferancing when I compile in unity?

May 17 '11 at 08:58 PM michael 4
(comments are locked)
10|3000 characters needed characters left

I don't think it's possible to directly set the mouse cursor position with Unity's own API (although it's likely possible if you use a custom DLL in a standalone build).

However, if your goal is to set the mouse cursor position in order to achieve a "mouse look" effect, there's a lockCursor command to do just this.

more ▼

answered Dec 24 '09 at 10:10 AM

duck gravatar image

duck ♦♦
41k 92 148 415

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

You can work around this problem, by basically manually implementing a GUI based mouse and moving it through the mouse delta given by Unity. You could then set the position of this mouse and just use static variables to access it from every script.

Wish unity would fix it, so we don't have to do these stupid workarounds.

more ▼

answered Jul 04 '12 at 10:33 AM

Benproductions1 gravatar image

Benproductions1
1.5k 5 13

(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:

x983

asked: Dec 24 '09 at 08:47 AM

Seen: 8773 times

Last Updated: Jul 04 '12 at 10:33 AM