Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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
0
Question by Kody · Oct 23, 2016 at 03:22 PM · texturemousetexture2dprocedural texturingmouse cursor

Creating Hardware Mouse Cursor Texture at Runtime

I'm creating a texture at runtime to use as a mouse cursor. Using something like :

  Texture2D moddedMouse = new Texture2D(mouseCursor.width, mouseCursor.height, mouseCursor.format, false, false);
  Color32[] bitmap = mouseCursor.GetPixels32();
  //stuff that edits the mouse cursor bitmap here
  moddedMouse.SetPixels32(bitmap);
  Cursor.SetCursor(moddedMouse, Vector2.one, CursorMode.Auto);


It works but Unity gives me this warning:

  Invalid texture used for cursor - check importer settings
  UnityEngine.Cursor:SetCursor(Texture2D, Vector2, CursorMode)
  Globals:UpdateCursorColor() (at Assets/Globals.cs:273)
  uStartMenu:Start() (at Assets/GUI/UGUI/uStartMenu.cs:50)

because Cursor.SetCursor() doesn't like a texture that isn't flagged as a "Cursor" type from the inspector. But I have no idea how to make a procedural texture "count" as a Cursor type. And I cant just create a Cursor and edit it at runtime because you cant set Cursor textures as read/write enabled.

Anyone know of a fix for this?

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
4
Best Answer

Answer by saschandroid · Oct 24, 2016 at 08:45 AM

Import the cursor texture you want to edit as Texture Type: Advanced. Enable read/write and alpha is transparency. Disable mipmaps and override color format to be ARGB 32 bit. Now you can edit and set it as cursor texture at runtime without warnings (tested unity 5.4.1f)

Comment
Add comment · Show 2 · 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 Kody · Oct 24, 2016 at 12:45 PM 0
Share

Thanks! It works with new Texture2Ds created from code as well, I was just forgetting to set "alpha is transparency".

avatar image Kody Kody · Nov 04, 2016 at 07:29 PM 0
Share

Bah. Never$$anonymous$$d apparently Texture2D.alphaIsTransparency only exists in the editor. It breaks building a standalone build. I can still fix it I'll have to create a bunch of textures in the editor :(

https://issuetracker.unity3d.com/issues/texture2d-dot-alphaistransparency-causes-build-to-fail

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

73 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 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 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 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

GUI texture to change texture when hovered over or clicked? 2 Answers

Assiging an Image to a Button 1 Answer

Delta event out of Editor Problem 4 Answers

Get Texture 2D after all shader passes are applied 0 Answers

Making texture cover whole button 1 Answer


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