Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 819
JigSawPsycho Avatar asked May 30 '26 09:05

JigSawPsycho


1 Answers

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.

like image 170
IndieGameDev Avatar answered May 31 '26 22:05

IndieGameDev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!