#How to load a subscene in a separate world?

1 messages · Page 1 of 1 (latest)

lunar turret
#

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.

faint carbon
#

get a subscene guid and load via static SceneSystem API

#

guid is available on SubScene monob

#

or technically it's also same as scene asset (could be wrong on that)

lunar turret
#

get a subscene guid and load via static SceneSystem API
yeah this is what I'm doing

tl;dr of above:
if I target the target world, that one needs to have scene systems in it, which I'm trying to avoid
I can load it into a separate world with scene systems, but I don't know if this is the right approach or how to move them over to the target world afterwards

faint carbon
#

I remember seeing discussion about copying entities from one world to another

#

check out World/WorldUnmanaged/EntityManager API

#

maybe it has something

lunar turret
#

so if I move all entities with a SceneTag after loading, everything seems to work
however it breaks the Entities Hierarchy window, because of:
ArgumentException: A component with type:Unity.Scenes.SceneEntityReference has not been added to the entity.

#

Unity.Entities.Editor.SubSceneMap.IntegrateChanges (Unity.Entities.World world, Unity.Entities.Editor.HierarchyNodeStore nodeStore, Unity.Entities.Editor.HierarchyNameStore nameStore, Unity.Entities.Editor.SubSceneChangeTracker+SubSceneMapChanges changes) (at ./Library/PackageCache/com.unity.entities@1.0.0-pre.65/Unity.Entities.Editor/Hierarchy/Model/SubSceneMap.cs:35)

lunar turret
#

seems this is a bug