Creating a Cursor in Unity

Dylan Rider Crow
3 min readAug 31, 2022

--

This article is going to show how to create a custom cursor in unity; in this demonstration a magic wand will be used.

Creating the Cursor

Pick out a png image that you want to use as your cursor. I used a magic wand shown below. (I recommend using a 2048 x 2048 pxl image and scale it down inside of unity).

This is a free image I found so if you'd like to use it feel free.

After you have selected the image you want to replace your cursor with, you need to altar it just a smidge to show when you click your mouse button something is happening.

I rotated it at the middle about 45 degrees to the left to make it somewhat simulate waving a wand, at least the flicking of a wand.

Import the wand into your Unity project folder

Drag and drop the png files into whichever folder you like in your project folder. I dropped them into my sprites folder.

Alter Image Settings to be a Cursor image type

Make sure all of your image properties match as above in the inspector. Under the max size set it to 64 which should make it an appropriate size of a cursor. You might have to play with the size for your own personal taste.

Coding your cursor

Lets look at the needed variables for this:

Texture2d → this is your initial cursor image

Texture2d → this is your clicked cursor image

those are the only mandatory variables you need. The others I have are listed because I spawn a animated sprite at my cursor and also have an audio click that plays when I click. If you want to do that as well then you can include those.

In the Start method you can easily change the cursors image with the Cursor.SetCursor method. The first property is your image variable you created and the second you want to keep Vector2.zero. The third property will also stay the same.

At this point your default cursor will be done and you can move forward with production. If you want to have it change though when clicking continue below:

In the Update method you want to have an if statement. If you click the mouse; set the cursor to the new image. If you lift the mouse button back up; set the cursor back to its previous image. All of the other code in the above image is to play the audio clip and to instantiate a sprite image at the mouse’s position.

Have fun with your cursor! Ill provide another free cursor below :D

--

--

Dylan Rider Crow

Hi, I am an avid game designer/game player. Game development is an artwork that not only requires creativity but critical thinking. #bestattributes