Hi, I’m looking to change the cursor on hover of a ui element.
To be clear, I’m NOT using a custom cursor sprite, I’m looking to change the system cursor in the same way it changes when hovering over a link in a browser (the pointing finger cursor).
I’ve done some searching through the .Net references, but I don’t seem to be able to access either the window control or cursor libraries from within Unity, and I can’t use the ‘EditorGUIUtility.AddCursorRect(rect, MouseCursor.Link);’ method either as this won’t work in a build.
Does anyone know of any way to change the system cursor in the same way regular programs do within a Unity build?
I can’t seem to find anything on Google that doesn’t involve using custom cursor sprites.
Use Cursor.SetColor(Texture2D, CursorMode). That should work!
And write a script that changes the cursor as you mouse over an object…
I think the browser just calls the same thing you would call, the Cursor.SetColor()
method.
I theorize that each browser just has a set of pointer graphics and by convention they’re the same.
If they are not, then maybe there is an operating system facility to obtain the graphics for each mode (caret, link, pointer, etc.), sort of like a “mouse pointer repository.”
Of course such a thing would be highly operating-system dependent. I suspect that Unity would not bother to expose such a facility since almost all games stylize their cursors anyway.
I haven’t done this sort of non-game cursor noodling in ages. I would just do my own cursor if I needed that kind of control… I’m allergic to all the weird edge cases that Cursor
has (it has a LOT of failure modes!) and do not have time to fiddle with crap like that.