I’m trying to create a persistent Entity (that doesn’t be destroyed in the chage of scenes).
You can find the project here: https://playcanvas.com/project/660089/ and debug the error.
Basically in the MainMenu scene there is the Loader entity that must persist during the change scene to the GamePlay one.
I’m trying to make a Singleton instance of this entity too.
From the main menu you can swap to the gameplay scene pressing the red button. The flow is this one:
- One you pressed the red button, the Loader load all the assets of the scene that you want to load and activate the LoadingScreen (a child of the Loader entity).
- Once the assets loading is complete, the Loader start loading the new scene.
- Once the Scene is loaded swap the parent of the Loader from the root of the old scene to the root of the new scene.
- Destroy the root of the old scene.
- Disable the LoadingScreen entity.
At the first swapping of scene, the process is completed without errors. Once you try to swap the scene again (pressing the ESC buttom from the gameplay scene), an error is raised when you try to achieve the 5th step (disable the LoadingScreen). It seems that a double change of parent node break something when you try to enable/disable an entity.
This behaviour happen from the second change of sceen. If you copy the Loader entity in the GamePlayScene and you start the project from that Scene, the first swap of scene is ok (from GamePlay to MainMenu) but the second one (form MainMenu to GamePlay) fails again in the same way described.
Someone already faced a problem like this?