Regarding events in AdvancedDynamicTexture, loaded using parseFromURLAsync

Hi everyone, im kinda new in BabylonJS. im try to get an event pointer to work on a button using the GUI. json file. json event loaded successfully. I can also console btnStart object. But events doesnt work so far, am i missing something.

var advancedTexture =
    BABYLON.GUI.AdvancedDynamicTexture.CreateFullscreenUI("GUI");
  let loadGUI = await advancedTexture.parseFromURLAsync("/assets/json/ui.json");

  if (loadGUI) {
    let btn = advancedTexture.getControlByName("btnStart");
    let panel = advancedTexture.getControlByName("panel");

    btn.onPointerClickObservable.add(function () {
      btn.isVisible = false;
      console.log(btn);
    });
  }

nvm managed to figure it out. it seems loadGUI is always null in my case, because is awaiting for result. when i remove the if statements all is well.

2 Likes