Problems with "LoadSceneHierarchy" method

Hello weveryone!

I have a big problem with LoadSceneHierarchy, until one month ago I used LoadScene() method to change my scenes with this script:

this.app.scenes.loadScene(scene.url, function (err, scene) {
        if (!err) {
            oldHierarchy.destroy();
            pc.ComponentSystem.initialize(scene.root);
            pc.ComponentSystem.postInitialize(scene.root);        
        } else {
            console.error(err);
        }
    });

And all works fine, with the new Engine Version this method failed and I change the code to this:

    this.app.scenes.loadSceneHierarchy(scene.url, function (err, scene) {
        if (!err) { 
            oldHierarchy.destroy();     
        } else {
            console.error(err);
        }
    });

The scene change but exist several problems like my inputs stop to work or the ilumination is completely different when change between scenes…

I suppose that i need to “restore” this two lines:

            pc.ComponentSystem.initialize(scene.root);
            pc.ComponentSystem.postInitialize(scene.root); 

The problem is that two lines return me an error that they aren’t a function…

Please give me a hand to fix this, I’m little desperate.

Thanks in advance guys!

We had a similar discussion on the GitHub repo here: https://github.com/playcanvas/engine/pull/3557#issuecomment-986619607

That should give you some options depending on your preference

Note: loadSceneHierarchy only loads the hierarchy, not the scene settings which will have properties like cubemaps. You will also need to call loadSceneSettings. The GitHub thread will explain more on this.

2 Likes

Man, you are awesome, your solution in GitHub post works PERFECTLY,

thank you!!!