How do I get the current scene name?

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 image 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 ="Main Scene");
console.log( // 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.

1 Like

@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.

1 Like

I had to do this now and I ended up here. I did it in a very silly way, but it worked :slight_smile:

in each scene I created an Entity with the same name as the scene. ex:
In scene 1
Entity: name_scene_0

In scene 2
Entity: name_scene_1

For all Root of the scenes, I created the following script:Screenshot_2

… and follow the .initialize script

Just note that you can load multiple scenes at once too if that’s a consideration :grimacing:

in my case it only worked because I used something like oldHierarchy.destroy ();