Custom Mouse Cursor Tutorial
03 November 2020
So today we are going to be making custom mouse cursor in unity.
Currently I am using Unity 2019.4.10
, So this can be applicable for future versions and maybe some older ones too.
We shall start with the default Sample Scene
I use VS-Code IDE as it is light weight, but you can use any IDE of your choice.
Download the assets here to get started along with me.
Lets start by creating a C# script and call it GameManager.cs
so this is the default script you will get
You can remove both the comments.
First we are going to declare 2 texture2ds before our start function and call them hand and pointer.
You can delete the Update function but leave the Start function as it is.
Now we will create 2 functions and call it setPointer and setHand.
You can use Cursor.SetCursor() function to set the cursor through script.
It requires 3 parameters texture vector2 hotspot and cursormode.
We`ll set the hotspot to 0,0 and cursormode to force-software.
And so this is the final script.
Now go into the unity editor and hit play.
Everything should work as expected.