SceneNode

Serializable graph node that pairs a Scene with a list of dependency nodes. Used internally by SceneGraph to form a directed acyclic graph of scene dependencies.

Definition

Namespace: Paragon.Core.SceneManagement Assembly: Paragon.dll

[Serializable]
public class SceneNode

Remarks

SceneNode is the building block of the SceneGraph. Each node holds a reference to a Scene and a list of other SceneNode instances it depends on. The SceneManager traverses these dependency links during GetDependencyChain() to determine the load order.

Dependency Validation

AddDependency validates that the target scene exists in the parent SceneGraph before adding it. This prevents dangling references to scenes not registered in the graph. The graph reference is injected via the constructor.

Serialization

Both the graph reference and the dependencies list use [SerializeReference] to maintain proper object identity during Unity serialization. This ensures that nodes reference the same SceneGraph and SceneNode instances rather than creating copies.

Quick Lookup

Goal
How

Get the scene

node.Scene

Add a dependency

node.AddDependency(scene)

Remove a dependency

node.RemoveDependency(node)

Check for dependency

node.HasDependency(scene)

List all dependencies

node.GetDependencies()

Properties

Property
Type
Access
Description

Scene

Scene

public

The scene this node represents

Fields

Field
Type
Access
Attribute
Description

scene

Scene

private

[SerializeField]

The wrapped scene reference

graph

SceneGraph

private

[SerializeReference]

Parent graph (for validation)

dependencies

List<SceneNode>

private

[SerializeReference]

List of dependency nodes

Constructors

SceneNode(SceneGraph, Scene)

Creates a node linked to a graph and wrapping a scene. Initializes an empty dependency list.

Parameter
Type
Description

graph

SceneGraph

The parent graph this node belongs to

scene

Scene

The scene this node represents

Methods

AddDependency

Adds a scene as a dependency of this node. The scene must exist in the parent SceneGraph.

Parameter
Type
Description

scene

Scene

The scene to add as a dependency

Behavior:

  1. If scene is not in the parent graph, logs "Scene {name} doesn't exits in the scene graph!" and returns

  2. If scene is already in the dependencies list, logs "Scene {name} already exists in the dependencies!" and returns

  3. Otherwise, looks up the SceneNode via graph.GetSceneNode(scene) and adds it to the dependencies list

RemoveDependency

Removes a dependency node from this node's dependency list.

Parameter
Type
Description

node

SceneNode

The node to remove

HasDependency

Checks if a scene is in this node's dependency list.

Parameter
Type
Description

scene

Scene

The scene to check

Returns: true if the scene is a dependency.

GetDependencies

Returns all dependency scenes as a flat enumerable (not the nodes themselves).

Returns: An IEnumerable<Scene> projected from the internal dependency node list.

ToString

Returns the scene name.

Common Pitfalls

circle-exclamation
circle-exclamation
circle-exclamation
circle-exclamation

Examples

Setting Up Dependencies

Querying Dependencies

Removing a Dependency

See Also

Last updated