简体   繁体   中英

Mac hardware cursor overlapping custom cursor unity c#

The game I am developing has a custom cursor. As a result of the cursor size, I have to use Cursor.SetCursor with CursorMode set to ForceSoftware (having CursorMode set to Auto squashes the cursor and doesn't look good at all). This works fine on windows, however on mac, the default mac cursor overlaps the software cursor, which as you can imagine doesn't look right. I have looked all over for a way to fix this, but I haven't had any luck. I have tried just setting the cursor in unity's player settings, but that distorts the cursor texture. At the moment it is just this line of code that sets the cursor

private void Start(){
    Cursor.SetCursor(cursor, new Vector2(-1, 1), CursorMode.ForceSoftware);
}

Where cursor is a Texture2D that I assign in the unity editor. I know this is probably a very simple problem to fix, but I really am not sure how to go about fixing it for mac systems.

The default mac cursor overlaps the software cursor

The problem lies within your Cursor.SetCursor code, because you are forcing the cursor to be a software cursor instead of the hardware cursor it needs to be.

Because some plattforms support only one hardware cursor and cursors created at runtime via. Cursor.SetCursor are seen as software cursors and don't " replace " the hardware cursor.

Example:

Cursor.SetCursor(cursorTexture, Vector2.zero, CursorMode.Auto);

The most important setting to make it work with Mac or other platforms that support only one hardware cursor is setting CursorMode.Auto . So it actually "replaces" the hardware cursor.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM