x


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?

Thanks

more ▼

asked Dec 10 '09 at 11:57 PM

Xin gravatar image

Xin
304 17 21 27

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

5 answers: sort newest
more ▼

answered Dec 28 '12 at 09:30 PM

dvochin2 gravatar image

dvochin2
51

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

Jan 08 at 10:03 PM Marrt

Good to know dvochin2

Mar 05 at 03:33 AM Khada
(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 at 02:38 PM

Indie.U gravatar image

Indie.U
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 '12 at 06:45 PM

magnussolidus gravatar image

magnussolidus
21 2

(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 '10 at 04:07 PM

bill gravatar image

bill
41 1 1 4

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

Jul 11 '12 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 '09 at 01:33 AM

Stelimar gravatar image

Stelimar
3k 14 16 50

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 '09 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 '10 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 '10 at 02:36 PM Cawas
(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:

x984

asked: Dec 10 '09 at 11:57 PM

Seen: 21861 times

Last Updated: May 04 at 02:38 PM