Creating 2D GUI: Scene class error

Hi! I’m working on a local typescript project that needs a 2D interface with buttons. I have intalled the babylonjs/gui package so i can use AdvanceDynamicTexture and Button classes but when i use

const advancedTexture = AdvancedDynamicTexture.CreateFullscreenUI("UI", true, this.scene, Texture.BILINEAR_SAMPLINGMODE, false);

This error takes place.

Argument of type 'import(".../node_modules/@babylonjs/core/scene").Scene' is not assignable to parameter of type 'import(".../node_modules/@babylonjs/gui/node_modules/@babylonjs/core/scene").Scene'.
Type 'Scene' is missing the following properties from type 'Scene': skipPointerDownPicking, _materialsRenderTargets, _geometriesByUniqueId, _activeMeshesFrozenButKeepClipping, and 2 more.

It seem like the Scene class from babylon/core/scene is not the same as the one in the babylon/gui package.
This is my package.json dependencies if that helps.

"dependencies": {
    "@babylonjs/core": "^5.0.0-beta.11",
    "@babylonjs/gui": "^5.4.0",
    "@babylonjs/loaders": "^5.0.0-beta.11",
    "vue": "^3.2.13"
  },

I didn’t find this error in any forum because everyone uses de babylon playground and when they call AdvancedDynamicTexture.CreateFullscreenUI() they only have to specify the name of the UI.

AdvancedDynamicTexture.CreateFullscreenUI("UI");

What can i do?

1 Like

Hello and welcome!

I believe that the answer is already here - About the problem of "@babylonjs/loaders": "^5.5.5", using BABYLON.SceneLoader.ImportMesh to report an error - #2 by labris

In other words, could you try to change all babylon related imports to the same version, like 5.5.5 - and have a look if it will work?

2 Likes

Welcome to the Forums, @Bowie! Sorry to hear about your frustrations.

I think @labris has the right of it here – you want to keep all your BJS packages on the same version, if not for sanity’s sake then to ward off issues like the one you’re experiencing.

aside: I wonder how we could help guide users away from falling into problems like this?

1 Like

It worked! Thank you very much @labris

2 Likes