Additive Scene Loading

I’m trying to properly load multiple scenes, which already works. I’m calling this.app.scenes.loadSceneHierarchy(someUrl) to load all the entities. So far so good :slight_smile:

Now when I look at the example given by you guys, before you call this.app.scenes.loadSceneHierarchy you call this.app.scenes.loadSceneSettings when changing scenes. I just want to make sure that my assumption is correct, that these setting are not only applied to the newly loaded entites, but instad are applied to the whole scene? They would overwrite the previous settings, of my base scene? So if I want to load additional scenes, I should not load these setting, but only the hierarchy, right?

Ofc this means, that the additional scene needs to work with the settings from the base scene, but is this assumption right? Or do I still need to load these settings?

Yes exactly, those settings aren’t for the entity hierarchy you load but for the scene (render, physics settings etc).

So if you don’t plan to overwrite the current scene settings, don’t call that function.

And you will have to make sure that all entities/level design can work with your base scene settings.

1 Like

As an extension to this question, I’m encountering some timing restrictions. If I load multiple scenes, they are all initialized immediately when their scene hierarchy is loaded. Therefore the order looks like this:

  • Main scene entities initialize()
  • Main scene entities postInitialize()
  • Additional scene 1 entities initialize()
  • Additional scene 1 entities postInitialize()
  • Additional scene 2 entities initialize()
  • Additional scene 2 entities postInitialize()

I’m currently working around this by firing events and relying on those instead of the initialize -> postInitialize order. But this is not very intuitive, so I was wondering if there is a way to delay the initialization process, until all scenes have been loaded?

Hi @AliMoe,

I’ve done something similar in the past and the way to go with it is override loadSceneHierarchy() method and create your own.

That method will load and append the new hierarchy and also call the initialize/postInitialize method on all new scripts. So you need to code a similar method, excluding that part.

2 Likes