Hi,
I’m trying the Babylon GUI. I’ve been using babylonjs ^5.0.0-beta.5 and babylonjs-gui ^4.2.1 . But everything errors out when I’m trying to create AdvancedDynamicTexture object:
const guiMenu = AdvancedDynamicTexture.CreateFullscreenUI('UI');
Once I’ve loaded this I keep getting errors:
Uncaught (in promise) TypeError: Cannot read properties of null (reading ‘_getComponent’)
Everything works just fine on the official babylonjs 4.2.1 . Is this because of beta? Or did GUI moved in 5.0 somewhere else?
roland
February 7, 2022, 7:01am
#2
Hi!
Do you mix the two versions? It’s not a good idea
roland
February 7, 2022, 7:06am
#3
I am doing it this way so the GUI classes are in a separate namespace
import * as GUI from '@babylonjs/gui'
private _setupGUI() {
const guiTexture = GUI.AdvancedDynamicTexture.CreateFullscreenUI('UI', true, this.scene)
this.gui = guiTexture
}
This works.
Yeah you were right, I was using two different versions. So I migrated to latest beta for all.
However it still errors out with the same error
Ok I think it was because of babylonjs and it’s working with @babylonjs /core . So when I changed the imports it all works just fine:
import * as BABYLON from '@babylonjs/core';
import { Engine, Scene, ArcRotateCamera, Vector3, Mesh, MeshBuilder, DirectionalLight, ShadowGenerator, Color4 } from '@babylonjs/core';
However with @babylon /core I don’t have access to debugLayer
roland
February 7, 2022, 7:37am
#6
The inspector is a devDepedency and you have to import it from a separate package.
import '@babylonjs/core/Debug/debugLayer'
import '@babylonjs/inspector'
1 Like
Ok it looks I have to pull everything from different modules. I’ve found this @babylonjs /inspector . Then just import everything with:
import '@babylonjs/core/Debug/debugLayer';
import '@babylonjs/inspector';
And it all works fine without any errors. Now it thinks I’m using React, but I’m using Vue. However everything seems to be working fine
roland
February 7, 2022, 7:40am
#8
What does it think? You mean the console logs? The inspector is made with React. I am a Vue fanboy too
Yeah, it’s not an error. Just funny
1 Like
roland
February 7, 2022, 7:46am
#10
So problem solved?
Edit: thanks for marking as a solution
roland
February 7, 2022, 9:34am
#11
One more thing here. Why do you import the whole BABYLON namespace?
Yeah I thought it was a good idea at start. I got rid of that already!
1 Like