Customise in-game cursor

Is there a way to change the look of the cursor in game? and have the cursor look differently based on conditions like mouse over?


more ▼

asked Dec 10, 2009 at 11:57 PM

avatar image

329 52 46 56

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

5 answers: sort newest
more ▼

answered Dec 28, 2012 at 09:30 PM

avatar image

81 1 1 2

what about getting the hardware cursor position, Input.mousePosition is still Update dependent afaik

Jan 08, 2013 at 10:03 PM Marrt

Good to know dvochin2

Mar 05, 2013 at 03:33 AM Khada

In which version of Unity did Cursor.SetCursor() get added?

Aug 29, 2013 at 01:04 AM cowlinator
Aug 29, 2013 at 01:21 AM magnussolidus
(comments are locked)
10|3000 characters needed characters left

Just go into project settings > Player > and set the cursor to whatever, then code it.

Happy Developing!

more ▼

answered May 04, 2013 at 02:38 PM

avatar image

26 1

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

It works fine but you forget to tell one thing:

This script draw the new mouse pointer as a GUI element, so it will be in a Layer. You should set the object with is drawing the new cursor in a Layer that will be above the others layers. If you don't do this, you mouse will simply dissapear when you aiming something on the GUI. =)

more ▼

answered Aug 05, 2012 at 06:45 PM

avatar image

61 3 2 4

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

Ya Unity needs a away to change the hardware cursor. Maybe someone should start a feature request. Unfortunately, I do not think it glamorous enough to get much attention.

Software cursors suck even with high frame rates they create a ghosting effect behind the real cursor.

more ▼

answered Jan 17, 2010 at 04:07 PM

avatar image

41 3 2 6

Yes, software cursors are no responsive as the hardware ones. But until then, you could perhaps use this: http://edrivenunity.com/cursors

Jul 11, 2012 at 04:35 PM dkozar
(comments are locked)
10|3000 characters needed characters left

There's no built-in function to set a custom mouse cursor, but you can make a script to do it yourself by simply hiding the cursor and drawing your own at the current mouse position. Something like this should work:

var cursorImage : Texture;

function Start() { Screen.showCursor = false; }

function OnGUI() { var mousePos : Vector3 = Input.mousePosition; var pos : Rect = Rect(mousePos.x,Screen.height - mousePos.y,cursorImage.width,cursorImage.height); GUI.Label(pos,cursorImage); }

Just attach it to a GameObject and drag and drop the image you want to use onto cursorImage. To change the cursor from another script, just change the cursorImage variable.

EDIT: As Lance mentioned in the comments below, with this method if your game suffers from low frame rates, the mouse will lag along with everything else. Unfortunately, there is currently no easy way around this that I know of.

more ▼

answered Dec 11, 2009 at 01:33 AM

avatar image

4.3k 19 40 77

It's important to know that drawing your own cursor is a software cursor as opposed to the normal one, which is a hardware cursor. What this means is that if your framerate is low or stuttery, moving the cursor won't be smooth. This is opposed to hardware cursors which remain smooth, regardless of CPU load. You might have experienced when your computer hangs, nothing is responsive except your cursor.

Dec 11, 2009 at 05:54 AM Lance Sun

Just an update, as of today there still seem to be no other solution for this issue. +1 for this. Even if it's not best, it's the only. And one thing: maybe it's better to use Texture2D rather than Texture. ;)

Oct 18, 2010 at 01:00 PM Cawas

also, there's a full script here which may interest someone: http://www.unifycommunity.com/wiki/index.php?title=Custom_2D_Pointer

Oct 18, 2010 at 02:36 PM Cawas

Stelimar, your simple script is workin fine but there's only one issue. the texture isn't located at the center of the cursor. I dunno how to change the values. I tried other script but they either woudn't work or had some issues! a little help here would be appreciated!

Aug 06, 2013 at 11:02 AM STARS
(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



Answers and Comments



asked: Dec 10, 2009 at 11:57 PM

Seen: 44926 times

Last Updated: Aug 29, 2013 at 01:21 AM