Vixen
02b45cc4
csharp
public sealed class SceneDocument

A scene, open for editing: a world, what is selected in it, and what things are called.

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

Remarks

The document Vixen.Editor.Core's README says arrives here rather than there, and the reason is the reference: a scene is an ECS world, and Vixen.Editor.Core does not reference Vixen.Ecs — deliberately, so that the command stack and the asset database are testable without one.

The editor names entities and the runtime does not. There is no name component: a name is worth thirty bytes per entity in every chunk of a shipping build to serve a panel that does not exist at run time. The map lives here, which also makes renaming an ordinary document edit with an ordinary undo entry rather than a structural change to the world.

Creating and destroying entities are undoable, and the handle survives. Create and Delete go on the stack; Add stays for a host building a scene from a file or a template. Five things come back and only the first was ever hard: the handle (World.TryRecreate), the components (a scratch world), the name, the stable id, and the entity's place among its siblings (Hierarchy.SetParentAfter) — see SubtreeSnapshot.

⚠ An undo of a delete can refuse. A slot taken since the delete makes its handle unrecoverable for ever, so the command throws rather than half-restoring a subtree. Reaching that needs something else creating entities in this world — a play-mode restore, or a second document.

Fields and properties (14)

  • public World World

    The world the scene lives in.

  • public SceneManager Scenes

    What loads and unloads scenes in that world.

  • public SceneHandle Scene

    Which scene this document edits.

  • public Selection<Entity> Selection

    What is selected, shared with the viewport, the hierarchy and the inspector.

  • public ISceneWriter? Writer

    Writes the scene back, or while nothing can.

  • public BehaviorStore Behaviors

    The behaviours the entities in this document carry.

  • public IReadOnlyList<Entity> Roots

    The entities in this scene that have no parent, in creation order.

  • public IEnumerable<Entity> Entities

    Every entity this scene owns.

  • public IReadOnlyDictionary<Entity, EditMesh> Meshes

    Every entity that carries geometry, with it.

  • public IReadOnlyDictionary<Entity, ShapeParameters> Shapes

    Every entity whose geometry is still generated, with what it is generated from.

  • public IReadOnlyDictionary<Entity, Dictionary<int, AssetReference>> Materials

    Every entity with a material on one of its groups, with the assignments.

  • public IReadOnlyDictionary<Entity, CsgNode> Booleans

    Every entity whose geometry is a boolean, with the node.

  • public IReadOnlyCollection<Entity> Hidden

    Everything the editor is not drawing, directly.

  • public IReadOnlyCollection<Entity> Locked

    Everything that refuses to be picked, directly.

Events (4)

  • public Action<SceneDocument>? StructureChanged

    Raised when entities appear, disappear or change parent.

  • public Action<SceneDocument, Entity>? Renamed

    Raised when an entity's name changes.

  • public Action<SceneDocument, Entity>? ComponentsChanged

    Raised when a component was added to or taken off an entity.

  • public Action<SceneDocument, Entity>? Marked

    Raised when an entity's visibility or lock changed.

Methods (41)

  • public EntityId IdOf(Entity entity)

    What names an entity in a file, rather than in this world.

  • public bool TryGetEntity(EntityId id, out Entity entity)

    Which entity a file's id names, if any.

  • public void Adopt(Entity entity, EntityId id)

    Says that an entity is the one a file called something.

  • public SceneDocument(EditorProject project, World world, AssetId asset, string title = "Scene")

    Opens a scene for editing.

  • public string NameOf(Entity entity)

    What an entity is called.

  • public bool TryGetName(Entity entity, out string name)

    Whether an entity has been given a name, rather than being shown as its handle.

  • public bool TryGetId(Entity entity, out EntityId id)

    The stable id an entity already has, without minting one.

  • public bool SetName(Entity entity, string name)

    Renames an entity without recording anything.

  • public bool Rename(Entity entity, string name)

    Renames an entity, undoably.

  • public Entity Add(string name, LocalTransform local, Entity parent = default(Entity))

    Adds an entity to the scene with a transform and a name.

  • public Entity Create(string name, LocalTransform local, Entity parent = default(Entity), Action<Entity>? initialise = null)

    Creates an entity, undoably.

  • public Entity CreateShape(PrimitiveKind kind, LocalTransform local, Entity parent = default(Entity))

    Creates an entity drawn as one of the built-in shapes, undoably.

  • public Entity CreateLight(LightKind kind, LocalTransform local, Entity parent = default(Entity))

    Creates a light, undoably.

  • public Entity CreateCamera(LocalTransform local, Entity parent = default(Entity))

    Creates a camera, undoably.

  • public bool Delete(IEnumerable<Entity> entities)

    Deletes entities and everything below them, undoably.

  • public bool Reparent(Entity entity, Entity parent)

    Hangs an entity from another one, keeping where it is in the world.

  • public bool Reparent(IEnumerable<Entity> entities, Entity parent)

    Hangs several entities from one parent, keeping where each is in the world.

  • public void Recomposed(Entity entity)

    Says a component came or went, for whatever is drawing them.

  • public bool IsHidden(Entity entity)

    Whether the editor is drawing an entity.

  • public bool IsLocked(Entity entity)

    Whether an entity refuses to be picked in the viewport.

  • public bool IsHiddenDirectly(Entity entity)

    Whether the entity itself carries the mark, ignoring its parents.

  • public bool IsLockedDirectly(Entity entity)
  • public void SetHidden(Entity entity, bool isHidden)

    Hides an entity in the editor, or stops hiding it.

  • public void SetLocked(Entity entity, bool isLocked)

    Stops an entity being picked in the viewport, or allows it again.

  • public EditMesh? MeshOf(Entity entity)

    The editable geometry an entity carries, or for none.

  • public bool HasMesh(Entity entity)

    Whether an entity carries editable geometry.

  • public void SetMesh(Entity entity, EditMesh? mesh)

    Gives an entity editable geometry, or takes it away.

  • public void TouchMesh(Entity entity)

    Says that an entity's mesh has been changed in place.

  • public int MeshVersion(Entity entity)

    How many times an entity's mesh has changed.

  • public ShapeParameters? ShapeOf(Entity entity)

    The live parameters an entity's shape still has, or .

  • public bool IsParametric(Entity entity)

    Whether an entity's geometry is still generated from parameters.

  • public bool IsPlainMesh(Entity entity)

    Whether an entity carries geometry that nothing generates any more.

  • public void SetShape(Entity entity, ShapeParameters? parameters)

    Gives an entity live parameters and the geometry they make, or takes them away.

  • public IReadOnlyDictionary<int, AssetReference> MaterialsOf(Entity entity)

    What material each of an entity's face groups is drawn with.

  • public void SetMaterial(Entity entity, int group, AssetReference material)

    Assigns a material to one of an entity's face groups, or takes one away.

  • public CsgNode? BooleanOf(Entity entity)

    The boolean an entity's geometry is derived by, or for none.

  • public bool IsDerived(Entity entity)

    Whether an entity's geometry is derived from its children rather than authored.

  • public void SetBoolean(Entity entity, CsgNode? node)

    Gives an entity a boolean, or takes one away.

  • public int PruneNames()

    Forgets the names of entities that are no longer alive.

  • public void Remap(IReadOnlyDictionary<Entity, Entity> translation)

    Moves the names across a play-mode restore's translation table.

  • protected override void SaveCore()

Used by (108, showing 40)

  • AddComponentMenuTestsVixen.Editor.App.Tests
  • AuthoringTestsVixen.Editor.AssetEditors.Tests
  • BehaviorAuthoringTestsVixen.Editor.App.Tests
  • BehaviorSceneTestsVixen.Editor.SceneView.Tests
  • BlockoutBooleanVixen.Editor.Blockout
  • BlockoutBooleanTestsVixen.Editor.Blockout.Tests
  • BlockoutCreateVixen.Editor.Blockout
  • BlockoutCreateTestsVixen.Editor.Blockout.Tests
  • BlockoutCubeGridVixen.Editor.Blockout
  • BlockoutGeometryVixen.Editor.Blockout
  • BlockoutGeometryTestsVixen.Editor.Blockout.Tests
  • BlockoutHandoffVixen.Editor.Blockout
  • BlockoutHistoryTestsVixen.Editor.Blockout.Tests
  • BlockoutModeVixen.Editor.Blockout
  • BlockoutSelectionTestsVixen.Editor.Blockout.Tests
  • BlockoutSurfaceTestsVixen.Editor.Blockout.Tests
  • BlockoutSurfacesVixen.Editor.Blockout
  • BooleanCommandVixen.Editor.SceneView
  • ClosingTestsVixen.Editor.App.Tests
  • CompiledSceneTestsVixen.Editor.AssetEditors.Tests
  • CompiledSceneViewVixen.Editor.AssetEditors
  • ComponentGizmoTestsVixen.Editor.SceneView.Tests
  • ComponentGizmosVixen.Editor.SceneView
  • ComponentTestsVixen.Editor.App.Tests
  • ComponentsViewVixen.Editor.App
  • CreateEntityCommandVixen.Editor.SceneView
  • CreateMenuTestsVixen.Editor.App.Tests
  • DestroyEntitiesCommandVixen.Editor.SceneView
  • DiagnosticsModuleVixen.Editor.Diagnostics
  • DiagnosticsPanelTestsVixen.Editor.App.Tests
  • DropIntoFieldTestsVixen.Editor.App.Tests
  • DropIntoSceneTestsVixen.Editor.App.Tests
  • EditMeshCommandVixen.Editor.SceneView
  • EditMeshSceneTestsVixen.Editor.SceneView.Tests
  • EditorAffordanceTestsVixen.Editor.App.Tests
  • EditorApplicationVixen.Editor.App
  • EditorModeTestsVixen.Editor.App.Tests
  • EditorSceneVixen.Editor.App
  • EditorSessionVixen.Editor.Testing
  • EntityLifetimeTestsVixen.Editor.SceneView.Tests