Skip to main content

Class SceneNetworkGraph

A directed node graph for managing scene-based flows. This graph facilitates linear or branched scene progression, and provides utility methods to traverse and retrieve scene references during runtime.

[CreateAssetMenu(menuName = "ScriptableObject/Scene Network Graph")]
public class SceneNetworkGraph : NodeGraph

Inheritance​

NodeGraph→SceneNetworkGraph

Methods​

GetCurrentScene()​

Returns the current scene referenced by the current node.

public SceneAssetReference GetCurrentScene()

Returns​

SceneAssetReference — The current scene reference, or null if unavailable.

GetNextScene()​

Retrieves the next available scene by traversing the graph.

public SceneAssetReference GetNextScene()

Returns​

SceneAssetReference — The next scene reference if found; otherwise, null if the end of the graph is reached or no scene is available.

GetStartNode()​

Finds and returns the start node in the graph.

public Node GetStartNode()

Returns​

Node — The start node, or null if it not exist.

HasReachedTheEnd()​

Checks whether the graph has reached an end node.

public bool HasReachedTheEnd()

Returns​

bool — true if the current node is an end node; otherwise, false.

OnAfterDeserialize()​

Callback that reset pointer current to null after deserialize.

public void OnAfterDeserialize()

OnBeforeSerialize()​

Callback that reset pointer current to null before serialize.

public void OnBeforeSerialize()

TryGetNextScene(out SceneAssetReference, out int)​

Attempts to traverse the graph from the current node to the next available SceneNode. If successful, returns its associated scene asset reference and the corresponding scene index.

public bool TryGetNextScene(out SceneAssetReference nextScene, out int index)

Parameters​

NameTypeDescription
nextSceneSceneAssetReferenceThe next available scene asset reference.
indexintThe index of the retrieved scene.

Returns​

bool — true if a scene is found; otherwise, false.

Remarks​

This method traverses the graph by moving the current node pointer according to the following rules:

  • Traverse only nodes that implement ITraversableNode, updating the current pointer at each step.
  • If current node is null, start at StartNode and update pointer.
  • Return scene reference when a SceneNode is found.
  • If current node is an EndNode or no next node to traverse, return false and null scene.
  • Methods
    • GetCurrentScene()
    • GetNextScene()
    • GetStartNode()
    • HasReachedTheEnd()
    • OnAfterDeserialize()
    • OnBeforeSerialize()
    • TryGetNextScene(out SceneAssetReference, out int)