Custom Cursor Reverts When Leaving UI Element

Hello,

I am currently working on a game, where when I click a button on the UI I am replacing my cursor with a targeting reticule. The clicking and it changing is fine, but the second I leave the item it reverts to a normal cursor. Is there a way to prevent this behavior?

I believe that the cursor system is for each element only. Once you leave the element it will revert back to default. What you need to do is set the cursor using this Unity - Scripting API: Cursor. This will change the cursor everywhere else.

1 Like

This sounds like expected behaviour. It’s the same as when your cursor changes to a hand when you hover over a link in your browser, but reverts back to default cursor once you are no longer hovering above the link.

1 Like

It would be expected for me if I was using the cursor setting on the element, but I am programmatically changing my cursor with Cursor.SetCursor on the click event. So there is no way then to update your cursor and not have it revert every time you pass a visual element?

This is a bug then, it shouldn’t do that. Please report it.

1 Like

We also created a custom cursor that changes when hovered over a selected hitbox area. On exit of the hitbox, the cursor however does not revert back to normal. We believe that when the action is sub-frame, that when the pointer exits, it does not revert.

Any thoughts on this? We are on the latest release version of Unity.

Check Unity - Scripting API: PointerLeaveEvent