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 BBrown4 · Aug 28, 2014 at 06:02 AM · c#guitexturecursor-customization

Cursor size with SetCursor or alternative?

I've been working with my own cursor in unity and it works beautifully except for one small issue, no pun intended. My custom cursor is TINY. I have made sure to set up the proper import settings on the texture and I have the max size set to 256 just to be safe. The image size is 63x63px and I've even resized it to 100x100px as a test, yet the cursor is stell VERY tiny in game.

I have found one solution using OnGUI() and DrawTexture using the mouse's position for the Rect. But that doesn't seem to work for me, as the texture does not show up for some reason.

Are there any other alternatives to re-sizing the cursor size so I can continue using SetCursor, it's so much cleaner. The file type for the cursor texture is .bmp, not sure if that may be causing conflicts or not.

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

1 Reply

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

Answer by BBrown4 · Aug 28, 2014 at 07:29 AM

I always answer my own darn questions. I apologize for having wasted anyone's time. Here is a tip for everyone out there who I know is not as dumb as I am. It might be a good idea to make sure the script component is actually turned on while trying to get something to work -__- I feel like an idiot haha. For anyone who comes along with this same issue, for now the solution that worked for me is the OnGUI() methid shown below:

 public Texture2D cursorTex;
     public int cursorSize = 63;
     int sizeX;
     int sizeY;
 
     void Awake() {
         sizeX = cursorSize;
         sizeY = cursorSize;
     }
 
     void Start() 
     {
         Screen.showCursor = false;
     }
 
     void Update() {
         sizeX = cursorSize;
         sizeY = cursorSize;
     }
 
     void OnGUI()
     {
         GUI.DrawTexture(new Rect(Event.current.mousePosition.x - (cursorSize/2), Event.current.mousePosition.y - (cursorSize/2), sizeX, sizeY), cursorTex);
     }

clearly the cursorSize would be your own size. I set it up the way I did because my crosshair/cursor will always have the same y size as the x size and doing it with the variables I did allows you to scale your cursor size directly from within the inspector with a single variable, however depending on your particular situation you may want to modify that in your own way.

Comment
Add comment · 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

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

2 People are following this question.

avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

How do I keep a Custom Cursor (GUITexture) on top of UnityGUI controls? 3 Answers

Toggle Only Works Once 1 Answer

Best way to change alpha on per object basis. (c#) 0 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