BABYLON.GUI.AdvancedDynamicTexture is constantly changing cursor to default

Hi there,

I have a problem that looks like a bug in BABYLON.GUI to me but I’m posting it in Questions for now as maybe it’s intended behaviour and there is a way around the problem.

I have some code that changes cursor in various situations, using code like that:
engine.getRenderingCanvas().style.cursor = “url(’…/images/some_cursor_image.png’) 12 12, auto”;

I have scene.doNotHandleCursors set to true and it all worked perfectly fine until I added this code at some point in my application:
BABYLON.GUI.AdvancedDynamicTexture.CreateFullscreenUI(“UI”);

Now, the change of the cursor happens for an extremely brief moment but any time mouse moves, the cursor is changed back to default.

It looks that the culprit is this code:
this._changeCursor("");
in babylonjs.gui.js that seems to be called on every pointer move.
I think this code should be enclosed in
if (!scene.doNotHandleCursors) clause, as it’s done in other places.

I can’t see an easy way around the problem, an obvious solution would be to change cursor every frame, after ADT does it but that seems very inefficient (particularly as cursor image is a png that needs to be loaded, I’m pretty sure browsers cache it but still).

Any ideas how to get around the problem? Or is it a bug and I should just report it as a bug?

Thanks

Jacek

hi @jacek ,

Welcome to the forum!

It does feel like it behaves incorrectly. Summoning @msDestiny14 :slight_smile:

Good morning @jacek and welcome to the forums! Do you have a pg example you mind sharing. I can take a look to make a repro as well. :slight_smile:

Update: nvm! I got it! Let me commit that for you: Bug fix for mouse by msDestiny14 · Pull Request #9947 · BabylonJS/Babylon.js · GitHub

2 Likes

Wow! That was fast :smiley:
I pointed my application to the latest preview release of Babylon.GUI and all my cursors now work perfectly fine!
Thanks @msDestiny14 for an exteremely quick bugfix!

Btw, you probably all know that, but Babylon.js is an amazing engine! I am converting a relatively complex game from 2D (using plain canvas) to 3D (using Babylon.js) and it goes surprisingly smoothly. What is particularly great is that I don’t need to adapt my game to how the framework wants it (which is unfortunately common for many frameworks and is a real pain if you have existing code), I can still keep my game loop and only change drawing code, code that deals with selecting things and stuff like that while keeping most of the code intact.

Thanks for welcoming me to the forums and thanks again for the quick fix!

2 Likes