• 3D
  • Problem with alpha / transparency when using a PNG as the mouse cursor

Hey all!

I'm having a problem. I'm trying to hide the mouse cursor while at the same time allow me to use its input and location so that I can place a marker on the 3D floor, but I'm running into problems making the mouse cursor transparent.

First off I'm trying to do two things: 1. Confine the mouse cursor to the window using Input.set_mouse_mode( Input.MOUSE_MODE_CONFINED ) and since I can't also use Input.MOUSE_MODE_HIDDEN to hide the mouse cursor, I've decided to... 2. Hide the mouse cursor using a 10x10 transparent .PNG image file. (I could even use a 1x1 but even that still shows a dot on the screen)

But the transparency alpha appears black, not transparent.

As a result I'm getting a mouse cursor that has a black 10x10 area. Here is a picture:

I checked the documentation (here: "Importing images") concerning (re)importing images and PNGs to get alphas to work but nothing seems to do the trick (unless I'm overlooking something). Here's my current import settings:

I would assume there is a way to set the alpha on a texture by scripting it but I can't seem to find the documentation and I also can't seem to figure out how to access and modify a texture or loaded resource from script. Help!

So either A) I have some image/import settings incorrect B There is a script I can use when loading a resource that would allow me to manually turn on the alpha transparency C) There is a simpler way to go about all of this to get both a CONFINED & HIDDEN mouse cursor (CAPTURED won't work because I still want to be able to swing the mouse cursor around on the screen)

Thanks TwistedTwigleg, yeah I tried both of those methods with no luck. They both produce a black image where there is transparency, those being

-Using project settings -Using a script

I've been digging around github bug reports and various things and it looks like a couple of other people are running into a similar problem, but it looks like the bug hasn't been resolved yet in the current stable release:

Here are the links: -"Cursors set with transparent textures have visual issues on Windows. #21745" -"Strange way to hide cursor with mouse modes #27889"

I'm gonna make a bug report of my own on github and hopefully draw some more attention to it, or perhaps someone on the code team has a solution, but in the meantime, I'm just hoping someone might have some special work-around they could recommend, perhaps something involving resources and textures that they might have run into.

Perhaps someone familiar with Godot open source code could help me find a quick solution that is pointing to something simple within the source code. I'll be on the Discord chats and reddit forums, too.

Until then, I'll probably just use a 1x1 image and try and use something that will blend in with the underlying marker that I'll eventually end up using in my game.

I mean, really, it would make sense if I could just set both HIDDEN & CONFINED, and especially if that were an option in the source code, perhaps create a 5th enum.

I spoke to aaronfranke on the Godot Discord about this whole mess of a problem and - bless his wee heart - he decided to take action and make a change to the source engine to give developers a bitwise choice with the mouse mode/mouse cursor option, which means we can do both HIDDEN & CONFINED by way of bitwise.

He's gone ahead and made the fix, set up a new branch and submitted a pull request, and is looking for developers to test his change on different devices (MacOS, Mobile, etc). Here are the relevant links:

Here's his Youtube video he made on how to download the source code and work with new branches (first six or seven minutes of the video): "Git and Build Workflow: How to Contribute to Godot using GitKraken"

Here's his pull request: "[WIP] Change MouseMode enum to be bitwise #43450"

Here's the issue discussion: "Allow the mouse to be both confined and hidden by changing the MouseMode enum to be bitwise #1810"