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 SceneNodeRemarks
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
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
Scene
Scene
public
The scene this node represents
Fields
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.
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.
scene
Scene
The scene to add as a dependency
Behavior:
If
sceneis not in the parentgraph, logs"Scene {name} doesn't exits in the scene graph!"and returnsIf
sceneis already in the dependencies list, logs"Scene {name} already exists in the dependencies!"and returnsOtherwise, looks up the
SceneNodeviagraph.GetSceneNode(scene)and adds it to the dependencies list
RemoveDependency
Removes a dependency node from this node's dependency list.
node
SceneNode
The node to remove
HasDependency
Checks if a scene is in this node's dependency list.
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
Dependencies must exist in the SceneGraph AddDependency validates that the scene is registered in the parent SceneGraph via graph.Contains(scene). If the scene is not in the graph, the dependency is silently rejected with an error log. Always AddScene to the graph before adding it as a dependency.
Duplicate dependencies are rejected Calling AddDependency with a scene that is already a dependency logs an error and does nothing. Check with HasDependency first if you need to guard against this.
RemoveDependency takes a SceneNode, not a Scene RemoveDependency accepts a SceneNode reference, not a Scene. This is because the SceneGraph.RemoveScene() method calls it directly with the node being removed. To remove by scene, you would need to find the node first via graph.GetSceneNode(scene).
Circular dependencies are not validated AddDependency does not check for cycles. Adding circular dependencies (A → B → A) will cause GetDependencyChain() in the SceneManager to loop indefinitely or produce unexpected results. Ensure your dependency graph is a DAG (directed acyclic graph).
Examples
Setting Up Dependencies
Querying Dependencies
Removing a Dependency
See Also
Scene — the scene reference held by each node
SceneGraph — the parent graph containing all nodes
SceneManager — traverses nodes for dependency chain resolution
SceneManagement Overview — system overview
Last updated