Hello Coders!
I am trying to reload the scene I am currently on. I have followed the example: https://developer.playcanvas.com/en/tutorials/changing-scenes/ which shows how to switch between two different scenes.
Now when doing it with the same scene I get an error.
Uncaught TypeError: Cannot read property 'enabled' of null
at ElementComponent.get (playcanvas-stable.dbg.js:28767)
at isEnabledAndHasEnabledElement (playcanvas-stable.dbg.js:38867)
at Array.filter (<anonymous>)
at LayoutGroupComponent.reflow (playcanvas-stable.dbg.js:38824)
at LayoutGroupComponentSystem._processReflowQueue (playcanvas-stable.dbg.js:38982)
at LayoutGroupComponentSystem._onPostUpdate (playcanvas-stable.dbg.js:38968)
at Function._helper (playcanvas-stable.dbg.js:28817)
at Function.postUpdate (playcanvas-stable.dbg.js:28837)
at Application.update (playcanvas-stable.dbg.js:48855)
at playcanvas-stable.dbg.js:49460
at sentryWrapped (helpers.ts:87)
Now this is fixed by destroying the old hirarchy first and then loading the new same one again.
var oldHierarchy = this.app.root.findByName('Root');
var scene = this.app.scenes.find(id);
oldHierarchy.destroy();
this.app.scenes.loadSceneHierarchy(scene.url, function (err, parent) {
if (err) {
console.error(err);
}
});
BUT it seems, that the hirarchy now is missing components. Some scripts do not have references to the entites that are set via attributes in the editor. Also my Camera does not have a camera component and my SoundManager does not have a sound component anymore.
Any ideas on how to achieve a clean reload of the scene?
Thank you for any help.
Bruno