Delay initialization of scene

Hey hey :slight_smile:

We are currently working on something like a permanent scene, one that can be loaded without settings, added to the current scene and which will persist throughout scene changes. This already works fine, we have some general manager scripts in it and we are able to properly use them everywhere.

The only issue lies in the scene in which we actually do add this permanent scene. Since loading the permanent scene takes some time, it will not be in place before the initialize method of script is executed.

@createScript("LoadPermanentScene")
export class LoadPermanentScene extends ScriptTypeBase
{
    constructor()
    {
        super();

        // This way this method will be executed on instantiation instead of on initialization. It is still too slow
        // and the promise will only resolve after postInitialize.
        this.tryLoadPermanentScene();
    }

    private static permanentSceneName = "Permanent";

    private tryLoadPermanentScene(): Promise<void>
    {
        if (SceneLoadingManager.isSceneLoaded(LoadPermanentScene.permanentSceneName)) return;
        SceneLoadingManager.loadPermanentScene(LoadPermanentScene.permanentSceneName);
    }
}

So my Question is, is there a way to delay the start of the application? As far as I saw it, it is already waiting for the asset registry to finish preloading. Is there a way to delay it even longer, to load another scene hierarchy and add it to the root entity?

Thanks

Just to understand this correctly, you want to load this scene before the app starts?

Thatโ€™s not possible unless you patch the start function of the Engine.

Could you disable the Root node of the scene until the permanent scene is loaded and then enable it then? That way, none of the scene is initialized until it is enabled.

Yeah, thats kinda it. I want the additional scene to be fully loaded before the inital scene is initialized.

Immediately disabling the current root entity and enabling it after I added the second scene is a good idea, I will try that. Thanks