Node

Represents a node in the engine's scene graph hierarchy.

Properties

IsActive

(bool) { get; set } = true: Gets or sets a value indicating whether the node is active.

Name

(string) { get; set } = "Node": Gets or sets the name of the node.

IsDestroyed

(bool) { get; set }: Whether the node was destroyed with its scene. A reference to it reads as missing: it is saved as null and never resolved to.

Parent

(Node?) { get; set }: Gets or sets the parent node of this node.

Children

(ObservableCollection) { get; set } = []: Gets or sets the list of child nodes.

Components

(Collection) = []: Gets the list of components attached to this node.

Transform

(Transform) { get; set } = new(): Gets or sets the transformation data for this node.

GlobalTransform

(Transform) { get; set }: Gets the cached global transformation of the node.

Public Methods

Awake

public virtual void Awake(Node? parentNew)

Recursively runs Awake on this node and all children. Call once after deserialization.

Parameters:

  • parentNew (Node?)

Start

public virtual void Start()

Runs EnsureStarted on all components in the subtree. Call once on first frame.

OnEnable

public virtual void OnEnable()

Called when the node becomes active or is enabled.

OnDisable

public virtual void OnDisable()

Called when the node becomes inactive or is disabled.

OnDestroy

public virtual void OnDestroy()

Called when the node is being destroyed.

OnLateUpdate

public virtual void OnLateUpdate(float deltaTime)

Called each frame after all Updates, for late logic.

Parameters:

  • deltaTime (float)

OnFixedUpdate

public virtual void OnFixedUpdate(float fixedDeltaTime)

Called at fixed time intervals for physics.

Parameters:

  • fixedDeltaTime (float)

OnUpdate

public virtual void OnUpdate(float deltaTime)

Called when the node needs to perform an update.

Parameters:

  • deltaTime (float): The time elapsed since the last update.

GetComponentsInChildren

public IEnumerable<T> GetComponentsInChildren()

Gets all components of type attached to this node and its children.

Returns: IEnumerable<T>

  • An enumerable of matching components.

HasComponent

public bool HasComponent()

Determines whether this node contains a component of type .

Returns: bool

  • True when a matching component exists; otherwise false.

AddComponent

public Component AddComponent(Component component)

Adds a component to this node.

Parameters:

  • component (Component): The component to add.

Returns: Component

  • The added component.

RemoveComponent

public bool RemoveComponent(Component component)

Removes the specified component from this node.

Parameters:

  • component (Component): The component to remove.

Returns: bool

  • True if the component was removed; otherwise false.

InvalidateGlobalTransformCache

public void InvalidateGlobalTransformCache()

Invalidates the cached global transform of the node and invokes the global transform invalidated event.

FindById

public static Node? FindById(Node? root, Guid id)

Finds the node with the given id in root's hierarchy, including the root itself, including inactive nodes so stored references can resolve consistently.

Parameters:

  • root (Node?): The hierarchy to search.
  • id (Guid): The node id to find.

Returns: Node?

  • The matching node, or null when none is found.

GetChildren

public IEnumerable<T> GetChildren()

Retrieves an enumerable collection of child nodes of a specific type.

Returns: IEnumerable<T>

  • An enumerable collection of child nodes of the specified type.

GetTypeAndChildren

public static IEnumerable<T> GetTypeAndChildren(IEnumerable<Node>? list)

Retrieves an enumerable collection of nodes of a specific type from a list of nodes.

Parameters:

  • list (IEnumerable?): The list of nodes to search.

Returns: IEnumerable<T>

  • An enumerable collection of nodes of the specified type.

GetComponent

public T? GetComponent()

Gets the component of type attached to this node.

Returns: T?

  • The component of the specified type, or null if not found.

GetComponents

public IEnumerable<T> GetComponents()

Gets all components of type attached to this node.

Returns: IEnumerable<T>

  • An enumerable of matching components.