#Hybrid ECS Scene Management?

1 messages · Page 1 of 1 (latest)

wary aspen
#

Is it possible to use SceneManager instead of SceneSystem to cleanly load and unload regular Unity scenes that may or may not include ECS subscenes? Specifically so that it nicely cleans up all ECS data when I unload them before moving on to the next?

sterile whale
#

And unload them

#

tie them to monob lifecycle for example

wary aspen
#

Are subscenes not automatically loaded and unloaded via the lifecycle of their parent scene?

sterile whale
#

Only if you have it checked

wary aspen
# sterile whale Only if you have it checked

I'm not sure if that is true. From what I'm looking at right now, the subscene is loaded in play mode regardless if it is checked in the Hierarchy. The difference between checked and unchecked as far as I can discern is whether Entities Hierarchy shows the subscene as 'closed' (but still populated with 'Entity (##:#)'), or when checked, the subscene is shown as 'Live Converted' with human readable names.

sterile whale
#

which will also create subscene entity

#

that entity at the same time can have any state

wary aspen
#

While just allowing the Unity scene manage the subscene seems to give me the behavior I want, although with

System.ArgumentException: All entities passed to EntityManager must exist. One of the entities has already been destroyed or was never created.

when switching from my ECS scene to my Mono-only frontend (maybe an inflight ECB straddling the unload). I seem to be getting brutal performance drops after the 2nd time loading the ECS scene. So I am guessing something isn't being cleaned up nicely.

I need to investigate further.

wary aspen
#

Looks like the spikes are listed under 'Others' in CPU Usage. And are manifesting as the EditorLoop taking an extra 20ms~. The odd thing is I can't seem to spot any actual information in the profiler that might point to what it is other than 'Others'.

wary aspen
sterile whale
#

wdym doesn't help?

#

SceneSystem.UnloadScene is the only right way

wary aspen
# sterile whale wdym doesn't help?

I'm seeing no lag spikes when loading into the ECS scene the first time, but the second time I'm seeing large spikes. By "doesn't help" I meant those manual ways of unloading the scene do no fix whatever is causing the game breaking spikes (i.e. seemingly no better than just SceneManager.LoadScene()). My current suspicion is that it might be physics or culling related, specifically some state being carried over between scenes regardless of unloads.

sterile whale
#

SceneManager.LoadScene() is sync verison which causes spikes afaik

#

and you want Async

fleet palm
#

you can't async load non-ecs scenes in the editor

wary aspen
fleet palm
#

do you have any entities-related editor windows open?

wary aspen
fleet palm
#

if closing teh ecs windows fixes it, that's a bug we should fix; if it doesn't fix it, i probably need to look at your project with superluminal to figure out what the editor is doing in those 14ms

#

the hierarchy view might have something, though

sterile whale
#

I did async loading between normal scenes

#

while recreating world from scratch

#

no stutters

wary aspen
fleet palm
#

how big is your project? uploadable in a bug?

wary aspen
#

Only 50mb. Ya I should be able to upload it in a bug.

fleet palm
#

awesome; be sure to post the number back here when you get one or i might miss it