Unity: How to switch scenes to a specific index

Hey was just wondering if this is the proper way to load scenes? It seems like when I can scene Switcher and go to a new scene, the previous scene objects are still active. I’m trying to go to a new scene and remove the previous scene and any objects with it. Any help is appreciated

    public goToScene(index: number) {
        this.switcher ??= this.getSceneSwitcher();

        const oldIndex = this.switcher?.currentIndex;
        this.switcher?.select(index).then(res => {
            // Need to unload the old scene or it wil save
            this.switcher?.scenes[oldIndex].unload();
        });
    }

Hi, previous scenes that are loaded by the SceneSwitcher will be unloaded by the SceneSwitcher.

If you want to switch your whole Needle Engine scene create an empty scene in Unity and just add an ExportInfo + SceneSwitcher component.

See the Multi Scenes example for reference.

Thanks that’s what I thought. I tried updating to the latest needle engine version and it seems to have fixed the issues

1 Like

This topic was automatically closed 13 days after the last reply. New replies are no longer allowed.