• 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 /
  • Help Room /
avatar image
1
Question by $$anonymous$$ · Apr 22, 2017 at 05:05 PM · scripting problemtexture2dcursorcursor-customization

Cursor.SetCursor() not working

I'm using Unity 5.6 and the Cursur.SetCursor() function doesn't seem to work. This is the script (Attached to an empty game object which is child of the camera):

 private void OnMouseEnter()
 {
         Cursor.SetCursor(cursorTexture, new Vector2(0, 0), CursorMode.Auto);
 }
 
 private void OnMouseExit()
 {
         Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
 }
 

Where cursorTexture is a Texture2D variable. It doesn't generate any error or warning but it just doesn't work at all.

I've also tried to change the cursor from Edit > Project Settings > Player but I get this warning "Invalid texture used for cursor"

This is the settings I'm using for the texture

alt text

I would like this to work through script because I don't want to always to have this kind of cursor. Thanks In advance.

texturesettings.png (29.7 kB)
Comment
Add comment · Show 4
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 PizzaPie · May 03, 2017 at 12:39 PM 0
Share

Tongle read/write enabled on the texture and apply the changes. It should work afterwards.

avatar image $$anonymous$$ PizzaPie · May 03, 2017 at 05:19 PM 0
Share

I've already tried, it doesn't work. I keep getting a warning

avatar image NlaakStudios · Jun 27, 2017 at 04:57 PM 0
Share

I am having the exact same issue. Using same Settings. Tried setting through Player Settings as well as Script. It works in editor but when I build executable I get just a black box.

What are we doing wrong - this seems like a basic brainless feature?

Is it Broke?

avatar image Insurikai_ · Jul 26, 2017 at 03:25 PM 0
Share

Does the GameObject you have this script on have a Collider of some type? If it doesn't then the Functions won't be called.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by NinjaPikachuu · May 03, 2017 at 07:47 AM

Im super noob to Unity, but maybe drag that into your scene, then make a prefab of it from your hierarchy. Then make that prefab your cursor texture.

Comment
Add comment · Show 1 · 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$$ · May 03, 2017 at 05:22 PM 0
Share

I'm not sure what you mean by that. If you're talking about the texture image then you're totally wrong. Anyways thanks for answering.

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

134 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 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

Cursor does not contain a definition for 'lockState'/'visible' 2 Answers

How to disable mouse lock script when returning to main menu 1 Answer

Set cursor position at the middle of the screen. 1 Answer

Need help with pause menu and cursor lock script conflict 1 Answer

Show cursor via collider 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges