How do I get the current scene name?
If you’re talking about where you can access the current scene’s name so you can change it, you click on the settings icon and then you click next to
SCENE NAME and give the scene it’s new name.
I want to get it through Script
Well, usually in order to switch scenes, you just get the scene’s code.
And if you don’t want to switch scenes, then I’m not really sure what you’re trying to accomplish.
You can access the scene name from the pc.SceneRegistryItem:
var sceneItem = this.app.scenes.find("Main Scene"); console.log(sceneItem.name) // Main Scene
There’s no way to get the ‘current’ scene as scenes can be load additively, multiple teams etc.
The best bet is to keep track yourself in the project.
@yaustar just wanted to check, but is this still the same case; that scenes can be loaded additively?
@Mark_Lundinnit sorry, not sure what you are asking ?
Yes, you can definitely load a scene hierarchy, add it to the existing hierarchy without removing the old one.
I had to do this now and I ended up here. I did it in a very silly way, but it worked
in each scene I created an Entity with the same name as the scene. ex:
In scene 1
In scene 2
For all Root of the scenes, I created the following script:
… and follow the .initialize script
Just note that you can load multiple scenes at once too if that’s a consideration
in my case it only worked because I used something like oldHierarchy.destroy ();