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
I would like this to work through script because I don't want to always to have this kind of cursor. Thanks In advance.
Tongle read/write enabled on the texture and apply the changes. It should work afterwards.
I've already tried, it doesn't work. I keep getting a warning
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?
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.
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.
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

Follow this Question
Related Questions
Problems with UI buttons and Cursor position (or) UI buttons and instantiated canvas. 1 Answer
Better way to edit RawImage texture data?,Better way to edit a RawImage texture? 0 Answers
LoadRawTextureData - how to use? 0 Answers
[SOLVED] Problems creating a Sprite through script 0 Answers
Can't see my custom cursor. 0 Answers