- Home /
Custom mouse cursor - looking for a really good tutorial.
Hey there, I've been searching for a while now and so far have only found solutions for using a custom mouse cursor in unity that have major problems with them.
Can anyone point me in the direction of a high quality (free) custom mouse cursor solution?
Most of the tutorials I have found seem to result in a mouse cursor that lags behind the "real" mouse cursor. I'm also struggling to find a tutorial that details the proper way to import an image for use as a mouse cursor and how to stop it from appearing blurry.
Can anyone who has already found a good solution save me trawling through a million google results? I just keep finding ones that suck a little bit.
Thanks very much!
Romano
Re: the image is blurry. This is typical when the image/texture (say, png for example) on import is left as a Texture in Unity. Select the image in your Assets and the Inspector panel, set Texture type to Cursor and scaling to point. For best results, the image should probably be power of two (if it's not, you'll see a warning in the bottom preview part)
Answer by fifthknotch · Mar 12, 2014 at 04:37 AM
Check this out. Open up your Unity project. Go to File => Build Settings. Click Player Settings at the bottom left corner of the window that opens. If you look at your inspector pane, you will now see your player build settings. The second image from the top is labeled "Cursor". Drag your custom 2D texture you would like to use as your cursor and voilà! custom cursor for all to see.
I didn't know about that, thanks fifthknotch.
The solution I'm looking for here is a much more flexible and code-based one if anyone has it. I'd like to be able to switch the cursor image at certain times using code. Specifically I'm looking for a really detailed tutorial if one exists.
Thanks :)
Code can be found here:
http://docs.unity3d.com/Documentation/ScriptReference/Cursor.SetCursor.html
This will change the texture given above.
Thanks again :D
Still would love to see a good tutorial if anyone knows where one is?
Unfortunately the above method only seems to work for me in unity but not in the build. I'd settle for a "decent" tutorial if anybody knows of one? :)
I don't have a tut but I do something like this...
public Texture2D currentCursor;
public Texture2D default;
public Texture2D outOfRange;
public Texture2D crafting;
... (drag/drop your images into those in Inspector)
Next I define an Enum for each CursorState
public enum CursorState {
default,
outOfRange,
crafting
}
public CursorState cursorState;
Then I have a method that's basically a switch/case which changes the currentCursor Texture2D to be whatever based on CursorState enum value is. Finally in my OnGUI I draw cursor
Also found this http://www.youtube.com/watch?v=$$anonymous$$36D5D$$anonymous$$m-tU
http://answers.unity3d.com/questions/145024/unity3d-custom-cursors.html