How to Load a Subscene into a Specific Scene (SceneSystem.LoadSceneAsync + Additive Setup)

Hi everyone,

We’re working on a Unity project using DOTS (Entities 1.4.0) and have a question regarding how to properly load subscenes into the correct Unity scene when using SceneSystem.LoadSceneAsync.


Context:

  • We have two Unity scenes:

    • MainMenuScene: Contains the main menu UI, lighting, camera, and post-processing volumes.
    • GameplayScene: Contains gameplay-specific config, camera, lighting, and its own post-processing stack.
  • When a player starts a session:

    1. We load GameplayScene asynchronously using SceneManager.LoadSceneAsync(..., LoadSceneMode.Additive) to avoid a noticeable freeze.
    2. Once GameplayScene has finished loading, we load a DOTS SubScene using SceneSystem.LoadSceneAsync.

Problem:

The DOTS subscene ends up being linked to the MainMenuScene, which is still the active scene at that point.

This becomes a critical issue because when we unload the MainMenuScene (after transitioning into gameplay), all entities loaded through the subscene are also destroyed, since their lifetime is tied to the scene they were linked to — in this case, the wrong one.

We want the subscene to be correctly associated with the GameplayScene so that its entities are preserved when the main menu is unloaded.


Question:

Is there a way to control or specify which Unity scene the subscene is “linked” to when calling SceneSystem.LoadSceneAsync?

Or is there a recommended workflow or best practice in DOTS to ensure the subscene is safely and explicitly associated with the gameplay scene, especially when using additive scene loading?

We’re deliberately avoiding LoadSceneMode.Single due to freezing/stalling, and are aiming for a smooth transition experience.

Any advice or guidance would be appreciated.
thanks!

If I’m understanding what you’re trying to do correctly, which is have a bunch of subscenes be able to be loaded at run time into a scene that they were not baked to, I don’t believe that’s possible at this time. You can have a subscene manager scene, which houses all your subscenes and allows you to switch between them.

Hey @DreamersINC,

Thanks for the quick response!

If I understand correctly, you’re suggesting using a dedicated scene a “subscene manager” that contains all subscenes and allows switching between them. Unfortunately, that approach doesn’t align with our use case.

We need to load the same subscene multiple times once for the client world and once for the server world** into the same Unity scene**, and we need full control over when and where it’s loaded.
A subscene manager or auto-loading via the Inspector wouldn’t work here, as it doesn’t support the runtime flexibility or multi-world context we require.

What we’re really looking for is a way to explicitly associate a subscene with a specific Unity scene context when using SceneSystem.LoadSceneAsync API, particularly in an additive loading setup. If there’s a known workaround or best practice for this in DOTS, we’d really appreciate any suggestion.

Thanks again!

You can do the with
SceneSystem.LoadSceneAsync(World.Unmanaged, SceneGUID);

I don’t believe you can change the scene they are linked to at runtime.
Remember that baking of the subscene happens at the build. So the reference is already attached.

This actually look like what you want to do which is store the EntitySceneRef in a component.

By the way, the documentation generally refers to subscenes as scenes so this API doesn’t allow to link a subscene to a specific scene. It simply loads a subscene and stores its data in an entity reference.
Thank you anyway :slight_smile:

anyone from unity has any thoughts about this ?

For anyone looking for a solution to this problem, simply set the newly loaded scene as the active scene using the SceneManager.GetActiveScene API.