Babylon GUI - Cannot read properties of null (reading '_getComponent')


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?

Do you mix the two versions? It’s not a good idea :slight_smile:

1 Like

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 :thinking:


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

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 :smile:

What does it think? You mean the console logs? The inspector is made with React. I am a Vue fanboy too :smiley:

Yeah, it’s not an error. Just funny :smile:

1 Like

So problem solved?
Edit: thanks for marking as a solution

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

Hello everyone, I checked the steps, but I have the same problem, do you think there is another reason?
Ekran görüntüsü 2022-09-13 144801
Ekran görüntüsü 2022-09-13 144822

Could you share a repro ?

Import Error: Unable to load from /assets/babylon5/booths/stant18.gltf: Cannot read properties of null (reading ‘0’)

I don’t understand what you mean by “repro” but the error code is above

sorry by repro I mean, could you reproduce in the playground ? or share a github TINY project ?

At a first glance it would seem you are missing the import ‘@babylonjs/loaders’

I got it, I’m sorry for not understanding :slight_smile: but the project is too big I’m a Jr developer so I can’t share it
I just want to summarize the problem briefly
In an area where I upload 12 objects, 1 of my objects is not always loaded due to this error 12/11 is loading 1 of them falls into the error section

We cannot unfortunately help without seeing actual code :frowning:

1 Like

Hi, I’m using a version 5.38.0 of “babylonjs-gui”

Updating the main “babylonjs” package to to the last version has solved my problem