Vixen
02b45cc4
csharp
public sealed class SceneManager

Scenes loaded into one world, additively, each unloadable on its own.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

Several scenes share one world — a level, its lighting, the UI, a streamed chunk of terrain — because the alternative, a world per scene, means every system runs once per scene and every query stops being able to see across them. Membership is a component, so unloading is a query and a destroy.

Unloading destroys whole subtrees. An entity in scene A parented to one in scene B is not forbidden — it is sometimes what a designer means — but unloading B destroys A's entity with it, because the alternative is a Parent pointing at a dead entity and every walk over the hierarchy throwing.

Fields and properties (2)

  • public World World

    The world the scenes live in.

  • public IReadOnlyList<SceneHandle> Loaded

    The scenes that are loaded, in the order they were.

Methods (10)

  • public SceneManager(World world)

    Creates a manager for a world.

  • public SceneHandle Create(string name)

    Opens an empty scene.

  • public string NameOf(SceneHandle scene)

    A scene's name.

  • public bool IsLoaded(SceneHandle scene)

    Whether a scene is loaded.

  • public Entity CreateEntity(SceneHandle scene)

    Creates an entity that belongs to a scene.

  • public Entity CreateTransform(SceneHandle scene, LocalTransform local)

    Creates an entity with a transform that belongs to a scene.

  • public void Adopt(SceneHandle scene, Entity root)

    Puts an existing entity, and everything below it, into a scene.

  • public SceneHandle SceneOf(Entity entity)

    Which scene an entity belongs to.

  • public int CountIn(SceneHandle scene)

    How many entities a scene owns.

  • public int Unload(SceneHandle scene, BehaviorStore? behaviors = null)

    Destroys everything a scene owns and forgets the scene.

Used by (17)

  • ProgramEcsStressTest
  • AppBuilderVixen.App.Hosting
  • AppServicesVixen.App.Hosting
  • NetworkSpawnSystemVixen.Net.Engine
  • NetworkSpawnTestsVixen.Net.Engine.Tests
  • NetworkSpawnerVixen.Net.Engine
  • SceneAndPrefabTestsVixen.Engine.Tests
  • SceneAssetVixen.Engine
  • SceneAssetTestsVixen.Engine.Tests
  • EntityLifetimeTestsVixen.Editor.SceneView.Tests
  • SceneDocumentVixen.Editor.SceneView
  • SceneDocumentTestsVixen.Editor.SceneView.Tests
  • SceneManifestTestsVixen.Editor.Assets.Tests
  • StartupSceneTestsVixen.App.Tests
  • MapAndHeartbeatTestsVixen.Live.Realm.Tests
  • MapLifetimeVixen.Live.Realm
  • RealmHostVixen.Live.Realm