Is there a way to get by name a GUI element?

Hello, ok I’m gonna be straight forward on this, it is possible to call a GUI element by name?

for context I created this GUI element let screenUI = BABYLON_GUI.AdvancedDynamicTexture.CreateFullscreenUI("UI"); and I need to dispose of it later in another place, can I call it by the name “UI”?

I searched on the docs but it doesn’t show a function that can work on my case, or at least that’s what I thought :frowning:

1 Like

did you try getTextureByName?
Scene | Babylon.js Documentation (

Otherwise you can dispose the screenUI as that method returns the texture.


for some reason “getTextureByName” is not being recognized as a property of scene, but no worries I solved my issue, I made the value a global variable in the class and I could solve the problem in that way, but if I could need the value in another place I will have in mind that property!

Thanks anyway for the answer :smiley:


Looks like it is a 5.0 feature (I see it in the what’s new). textures is a public property on scene:

public getTextureByName(name: string): Nullable<BaseTexture> {
        for (var index = 0; index < this.textures.length; index++) {
            if (this.textures[index].name === name) {
                return this.textures[index];

        return null;

edit: if you have coalescing operator, you can just do scene.textures.find(t => === name) ?? null;


I was able get a GUI element by name. Here are the steps that I took to do this. They are done inside of different functions within the larger createScene.

First, I added the GUI as a var in my createScene function, that way I could call it globally.

var dashboard = BABYLON.GUI.AdvancedDynamicTexture.CreateFullscreenUI("UI");

blah blah blah, return scene. 

Then I added a bunch of objects to my ‘dashboard’ object.

var rect1 = new BABYLON.GUI.Rectangle("mybox");
	rect1.width = .06;
	rect1.height = .03;
	rect1.cornerRadius = 10;
	rect1.color = "white";
	rect1.thickness = 4;
	rect1.background = "black";
	rect1.linkOffsetY = -15;

var label = new BABYLON.GUI.TextBlock("mytext");
	// following:
	label.text = "I would like to change this later.";
	label.height = "40px"

later, I was able to query the dashboard for that item.

searchedLabel = dashboard.getControlByName("mytext")
searchedLabel._text = "Huzzah!" 

Note that these happen in different scopes. So in the last one I was able to access the dashboard, but not the label.
However, I was able to search the dashboard for the label by name.