Switch state, dispose old scene then attach new scene shows nothing

Playground Link

I need to load new scene and dispose the old one. But it shows nothing.

Set ActiveCamera like this post doesn’t work

Thanks for helping!

Solution:
The problem is solved by 2 actions:

  1. Change the scene target when create guiMenu

const guiMenu = AdvancedDynamicTexture.CreateFullscreenUI(‘ui’, true, sceneToLoad);

  1. Add active camera after change scene from old scene to new scene

The second actions should be the difference between Babylon version 5 vs 6
In version 5, no need active camera, version 6 needs it

The PG you posted has multiple issues to begin with

  1. doesn’t work at all
  2. it’s a ts type code, but it’s a js type pg
  3. you imported your local project, so it’s different from PG’s render rules

Here’s what we found
If I press a button in scene 1, scene 2 (maybe Game?) should run after scene 1 is discarded?

Maybe what you’re missing is the part about dispose and render.
check PG then tell me if there are any more special conditions
https://www.babylonjs-playground.com/#KC5W6L#13

2 Likes

Generally speaking, if it is entered as a parameter of a scene when created, it will be inherited by the scene and removed on dispose, and you will need to create a new one.

ex

var camera = new BABYLON.ArcRotateCamera(“Camera”, 5, 1, 15, new BABYLON.Vector3(0, 0, 0), scene );

2 Likes