#Scene Loading with ECS

1 messages · Page 1 of 1 (latest)

left solstice
#

TL:DR What is the correct way to load a scene with a subscene with ECS?

In normal MonoBehaviour we build the Scenes and load them when they are needed with the SceneManager.LoadSceneAsync().
Either Single or Additive Loading and manage the other scenes rather simple how we like everything to happen.

Now I have been trying ECS for quite some time and can't get my head around why my SubScenes are not loaded when I load a new Scene. The Documentation says something about that it will be autoloaded when it is set to true - which it is.
There are quite some Tutorials out there, but all of them are just loading the SubScenes in and out of one "Main Scene".

Is this actually the Way to load things?
From what I remember only things that change should go into SubScenes.

violet hollow
#

Do you mean you have multiple scenes each has its own set of subscenes, and you want to load those subscenes along with their containing scene?

#

If yes, then I've done that for my past 2 projects, just by using the Subscene component and enable the Auto Load option on it.

#

But I only load, never unload, so it might be different from what you want to achieve.

#

To sum up, I only use SceneManager.LoadSceneAsync to load the scenes as well as their subscenes. I didn't use the SceneSystem from Entities.

mossy gale
#

I use SceneSystem to load subscenes before my regular scenes as for now I have some hooks from gameobjects and I need my subscenes loaded already

violet hollow
#

Then the OP is not an issue anymore because you've changed your workflow?

left solstice
#

Good Morning!
@violet hollow I actually tried loading it like this.
In the Entities Hierarchy I can see the Entities getting initialized correctly.
But they dont render in. I have the Entities Graphics Package - reimported multiple Times by now.
Whenever I start FROM the Scene itself everything renders. But when I load the Scene with the SubScene nothing renders at all. Either I am doing something wrong - or I am at a loss here.

The SubScene is configured like this. But still it doesnt seem to Auto Load at all.

#

!code

stuck ibexBOT
left solstice
#

This is how I try to load the Scene - maybe I'm not seeing something here.

        IEnumerator LoadScene()
        {
            yield return null;
            
            AsyncOperation asyncOperation = SceneManager.LoadSceneAsync("OutdoorsScene", LoadSceneMode.Additive); // TODO Make Dynamic
            asyncOperation!.allowSceneActivation = false;
            Debug.Log("Progress :" + asyncOperation.progress);
            
            //When the load is still in progress, output the Text
            while (!asyncOperation.isDone)
            {
                Debug.Log("Progress :" + (asyncOperation.progress * 100) + "%");
                // Check if the load has finished
                if (asyncOperation.progress >= 0.9f)
                {
                    asyncOperation.allowSceneActivation = true;    
                }

                yield return null;
            }
            
            Debug.Log("Progress :" + (asyncOperation.progress * 100) + "%");
            Scene serverScene = SceneManager.GetSceneByName("OutdoorsScene");
            SceneManager.SetActiveScene(serverScene);
            Debug.Log("Scene Load Done...");
            SceneManager.UnloadSceneAsync("ServerBootScene");
            CreateServerEndpoint();
        }
unique creek