can open or close Subscene by script?

Hello, I’m using subscene and I want to open subscene by script.
Because I found when I built project by new build configuration, it seems not opened the subscene even I opened in editor before I build.
So I’ve experimented in editor by using LoadSceneAsync method.
It looks like the subscene loaded well, but still in closed.
I wonder if there is a way to open subscene by script.
Thanks for reading.
By the way I’m using Entites 0.51 package and unity 2020 LTS(3.37f1).

ofcourse u can do that.

  1. Get SceneSystem
  2. SceneSystem.LoadScene( guid ) (u can get guid on go’s subscene)

Does this mean LoadSceneAsync? cause I’ve got this error.

  • error CS1061: ‘SceneSystem’ does not contain a definition for ‘LoadScene’ and no accessible extension method ‘LoadScene’ accepting a first argument of type ‘SceneSystem’ could be found (are you missing a using directive or an assembly reference?)

And I’ve already tried LoadSceneAsync which just load not open the subscene.

1 Like

my fault,that is LoadSceneAsync, show me your code.

Brefly, this is my code.

public SubScene prefabScene;

private void Start()
{
  sceneSystem = entityManager.World.GetOrCreateSystem<SceneSystem>();
  sceneSystem.LoadSceneAsync(prefabScene.SceneGUID);
}

and this is what happening on my editor.
8359275--1100403--unity_before_start.png 8359275--1100406--unity_after_start.png

Is it possible to detect when a subscene is closed? I don’t see an event, and nearly all the functions in SubScene.cs are private by default so I can’t inherit SubScene and override a function such as AddSceneEntities() or OnValidate() without changing the source code of SubScene.cs itself.