Search Unity

Feature Request Better API For Setting Cursor Texture

Discussion in 'UI Toolkit' started by Nexer8, Sep 13, 2021.

  1. Nexer8

    Nexer8

    Joined:
    Dec 10, 2017
    Posts:
    271
    Currently, you need to set the cursor texture using a Texture2D, which might work if you use custom cursors for your application that should look the same across multiple operating systems, but in most cases you want the OS cursors for specific elements. A button should have the hand, a draggable element should have a grabbing hand etc. The Windows hand on a Mac would look weird, and the Mac default cursor would look weird on Windows.

    Some form of CursorUtility to bridge the gap would be useful:

    I imagine it could look something like this:
    Code (CSharp):
    1. var cursorTex = CursorUtility.Hand;//Returns the hand cursor default to each OS
    or even better for easy changes:
    Code (CSharp):
    1. var cursorTex = CursorUtility.Cursor(CursorMode.Grab);//Return the grab cursor default to each OS
    In the UI Builder you could have an enum for the different cursors where the first option is custom.