Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
3
Question by CanCo · Dec 16, 2012 at 03:46 AM · cursor4.0

Creating a custom cursor.

How do I create a custom cursor? When I set my cursor image in the player settings it just gives me a gray box as the cursor.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
16
Best Answer

Answer by Eric5h5 · Dec 16, 2012 at 05:43 AM

Try setting the texture type to Cursor, and limiting the size to 32x32. I found that while setting the cursor in the player settings worked in the editor, it did not show up in a build. I worked around that by using Cursor.SetCursor in a script instead.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image clunk47 · Dec 16, 2012 at 06:13 AM 1
Share

+1 for explaining HW Cursors, I always appreciate fair mannered explanations. :)

avatar image lalodoble · Oct 07, 2013 at 05:01 PM 0
Share

I did that, but still dont know what parameter put on Cursor.SetCursor(). Any help? Thanks

avatar image clunk47 · Oct 07, 2013 at 05:55 PM 1
Share

Cursor.SetCursor()

avatar image Spitfire47 · Oct 12, 2013 at 02:37 PM 2
Share

There is an even easier way. Click on your custom cursor's texture to see it's settings in the Inspector, then click on "Texture Type" and click "Cursor". Now it works!

avatar image
3

Answer by clunk47 · Oct 07, 2013 at 05:58 PM

You could also use GUI.DrawTexture like so:

     var mouse : Vector2;
     var w : int = 32;
     var h : int = 32;
     var cursor : Texture2D;
     
     function Start()
     {
         Screen.showCursor = false;
     }
     
     function Update()
     {
         mouse = new Vector2(Input.mousePosition.x, Screen.height - Input.mousePosition.y);
     }
     
     function OnGUI()
     {
         GUI.DrawTexture(new Rect(mouse.x - (w / 2), mouse.y - (h / 2), w, h), cursor);
     }
Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image $$anonymous$$ · Sep 02, 2014 at 02:51 PM 2
Share

Wow...@clunk47 Thanks very much ! It worked for me. =)

avatar image DragonautX · Nov 10, 2016 at 07:14 PM 0
Share

This is helpful. Adds more flexibility to cursor size. I never knew Screen and GUI existed. Screen.showCursor is deprecated now to UnityEngine.Cursor.visible, but other than that, I like this answer. Thanks!

avatar image Cohav0310 · Apr 17, 2018 at 02:51 PM 0
Share

@clunk47 The script does work in adding the cursor into the environment. It does follow the mouse, sort of. It never seems to be fully in synch to where the mouse is. It seems to be offset slightly. How do I fix this?

avatar image Harinezumi Cohav0310 · Apr 17, 2018 at 03:02 PM 0
Share

$$anonymous$$aybe you need to modify the hotspot of the cursor (offset of click location from top left corner of the cursor image). Check this (old) Unity blog entry for more info about custom cursors.

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

16 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Cursor Lockmode only works once? 1 Answer

Cursor bug 0 Answers

Keep Cursor at center and project interactions to cursor position on mobile touch devices (IOS) 0 Answers

Cursor.lockState does not work 2 Answers

Get button down disable and enable cursor 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges