UGTK / Toolkit / Ui Module / Mouse Over System Completed
Mouse Over System
Summary
The Mouse Over System swaps the hardware cursor while the pointer is over an object, and puts the
system one back when it leaves.
It is the "this is clickable" hint: a hand over a button, crosshairs over a target, a magnifier over a zoomable map. One component per object, no script to write.
Content
Modules Dependencies
None inside UGTK. It uses Unity's EventSystem and Cursor.SetCursor.
Setup
- Add
Mn_MouseOverto the object that should change the cursor. - Assign Cursor Texture in the inspector.
The object has to be reachable by the EventSystem, which means one of two things: a Graphic with
Raycast Target on if it lives on a canvas, or a collider plus a Physics Raycaster on the
camera if it is a world object. Without that the pointer events never arrive and the component does
nothing at all — there is no error to tell you.
How To Use
There is nothing to call: the component reacts to the pointer entering and leaving on its own.
Three things are worth knowing before you ship it.
- With no texture assigned the cursor is hidden, not changed. That is a legitimate effect — it is how you hide the pointer over a custom-drawn cursor — but it also happens when you simply forgot to fill the field, and the two look identical.
- The texture must have Read/Write enabled in its import settings. Without it
Cursor.SetCursorrefuses the texture and the system cursor stays exactly as it was, silently. - The hotspot is the top-left corner. The component passes
Vector2.zero, so a crosshair drawn in the middle of its texture will point at its corner, not at its centre. If you need the click point elsewhere, that is a change to the component.
Keep the texture small. A cursor is drawn by the OS at its native size, so a 512×512 image does not give a crisper pointer — it gives a huge one.
Testing Scene
The inspector also carries an Editor Test Tools block that simulates the pointer entering and leaving, so the texture can be checked without entering Play Mode and hovering by hand. It previews the assigned cursor at its real size and warns about the two traps above — no texture assigned, and Read/Write disabled.
Technical Info
| Path | Content |
|---|---|
Scripts/Mn_MouseOver.cs |
The component. Implements IPointerEnterHandler and IPointerExitHandler; applies the texture on enter and restores the system cursor on exit |
Scripts/Editor/Mn_MouseOverEditor.cs |
Inspector: cursor preview, the Read/Write check, and the two simulate buttons |
© 2026 Marcello De Bonis. All rights reserved
UGTKengine within an engine


