I want to load/unload subscenes but can’t figure out how. I have seen talk of RequestSceneLoaded but not exactly how to use it.
Code example below. Note that you need to do it as a ComponentSystem and not a JobComponentSystem so it will run on the main thread.
using Unity.Entities;
using Unity.Scenes;
public class ToggleSubSceneSystem : ComponentSystem {
protected override void OnUpdate() {
Entities.ForEach((Entity entity, SubScene scene) => {
if (EntityManager.HasComponent<RequestSceneLoaded>(entity)) {
EntityManager.RemoveComponent<RequestSceneLoaded>(entity);
} else {
EntityManager.AddComponent<RequestSceneLoaded>(entity);
}
});
this.Enabled = false;
}
}