Can someone explain ecs scene management to me? Here's what I could gather so far:
There's a couple of systems for subscenes:
- EditorSubSceneLiveConversionSystem
- SceneSectionStreamingSystem
- WeakAssetReferenceLoadingSystem
- SceneSystem
- ResolveSceneReferenceSystem
Let's say I want a LoadingWorld that loads the subscene, and a GameWorld that needs the loaded subscenes. I add the above systems to LoadingWorld. GameWorld should receive loaded entities but not do any loading itself.
If I call the following code:
var entity = SceneSystem.LoadSceneAsync(loadingWorld.Unmanaged, subScene.SceneGUID);
loadingWorld.EntityManager.AddComponentObject(entity, subScene);
And run loadingWorld.Update() a few times, it loads the subscene entities into LoadingWorld.
Q1: What is the best way to move these from LoadingWorld to GameWorld? Seems EntityManager.MoveEntitiesFrom tries to also move unwanted ISharedComponentData and whatnot that is created by the scene systems. Or maybe this is the wrong approach altogether? See Q2 and Q3.
Q2: How do the streaming worlds work that Unity automatically creates (LoadingWorld0-3)? It seems that when calling LoadSceneAsync, subscene entities get loaded into one of these worlds and then moved to the target world. Is that assumption correct?
Q3: So then, it seems what I'm trying to do above is:
LoadingWorld calls load > Subscenes load into UnityLoadingWorlds > Move from UnityLoadingWorlds into LoadingWorld > Move from LoadingWorld to GameWorld
Is there a way to avoid the extra steps? Either from UnityLoadingWorld directly into GameWorld, or skip UnityLoadingWorld somehow. Seems if I pass GameWorld instead of LoadingWorld into LoadSceneAsync, I also need the scene loading systems in GameWorld which is what I'm trying to avoid.