To set a custom mouse pointer when the mouse moves over a UI control GameObject, do the following:
- Create a new Unity 2D project.
- Import the provided IconsCursors folder. Select all three images in the Project panel, and in the Inspector change the Texture Type to Cursor. This will allow us to use these images as mouse cursors without any errors occurring.
- Import the provided _Scripts folder, containing the CustomCursorPointer C# script class.
- Add a UI Button GameObject to the scene, leaving this named as Button.
- Add an instance of the CustomCursorPointer C# script class to the Button GameObject.
- With the Button GameObject selected in the Hierarchy, drag the CursorZoom image into the public Cursor Texture 2D variable slot ...