Skip to content

Entity

namespace Griff.Scenes;
public sealed class Entity

A thing in a scene: a name, a Transform, any number of other components, and child entities. Hierarchy changes go through Scene.

public IReadOnlyList<Entity> Children { get; }
public IReadOnlyList<Component> Components { get; }

All components, starting with Transform.

public Guid Id { get; }

Stable identity, preserved across saves, renames and moves.

public bool IsActive { get; }

True if this entity and all its parents are IsEnabled: the game runs and draws it.

public bool IsEnabled { get; set; }
public bool IsHidden { get; set; }

Hidden in the editor: the Scene view doesn’t draw it (or anything inside it), so clicks and box selections don’t find it, though the Hierarchy still selects it. The game ignores it and shows it as usual.

public bool IsHiddenInHierarchy { get; }

True if this entity or one of its parents is IsHidden.

public bool IsLocked { get; set; }

Locked in the editor: clicks and box selections in the Scene view pass through it (and everything inside it) to what’s behind, though the Hierarchy still selects it. The game ignores it.

public bool IsLockedInHierarchy { get; }

True if this entity or one of its parents is IsLocked.

public bool IsPaused { get; }

True while the game holds this entity still: it, or something it’s inside, is a paused group (a PauseGroup that’s Paused, or what an open panel or a dialogue being said pauses). Nothing in a paused group moves, animates, runs its scripts or takes input, but it’s still drawn and still solid to what’s outside, and the rest of the game runs on.

public string Name { get; set; }
public Entity? Parent { get; }
public string? Prefab { get; set; }

The prefab this entity is a placed copy of, as the prefab file’s path in Assets (“Prefabs/Coin.prefab”), or null. Saving the prefab in the editor brings the copy up to date. The game ignores it.

public PrefabVersion? PrefabVersion { get; set; }

For a placed copy (Prefab), the version of the prefab it was made from or last brought up to date with: what the copy changed is what differs from it, so the editor keeps those changes when the prefab changes, however it changed. Null for a copy made before copies remembered it. The game ignores it.

public Scene? Scene { get; }
public Transform Transform { get; }
public void AddChild(Entity child)

Puts child last inside this entity while neither is in a scene: an entity being built before it goes into one (a template’s, a prefab’s). An entity in a scene moves with Move.

public T AddComponent<T>()
public Component AddComponent(Component component, int? index = default)

Attaches component, at index if given (used by undo).

public T? GetComponent<T>()
public IEnumerable<T> GetComponents<T>()
public bool IsSelfOrDescendantOf(Entity other)

True if this entity is other or one of its descendants.

public void MoveComponent(Component component, int index)

Moves component to index among the components; the Transform stays first.

public bool RemoveChild(Entity child)

Takes child out of this entity while it isn’t in a scene (see AddChild).

Returns whether it was inside this one.

public bool RemoveComponent(Component component)

Returns false if the component isn’t attached to this entity.

public void ReplaceComponent(Component existing, Component replacement)

Swaps existing for replacement at the same position (used by script reload).

public IEnumerable<Entity> SelfAndDescendants()

This entity and all its descendants, depth first.

public override string ToString()