SystemGraph overview
This page offers an overview of the core concepts of SystemGraph.
System graph asset
A system is a composition of modules and subsystems, represented as a schematics graph, called a system graph.
SystemGraph aims to emulate modules from different engineering fields and deliver a coherent and scalable solution in a single tool.
System Graph Component
The System Graph Component manages the lifecycle of the SystemGraph nodes at runtime. It's the coordinator of events and instantiates the resources needed for the graph, from the system graph asset. It's bound to a GameObject and receives standard Unity lifecycle events.
It also allows to set or inspect values of the graph properties and to bind GameObjects or assets to node bindings, using the Inspector window.
SystemGraph Editor
The SystemGraph Editor is a graphical tool which provides a visual representation of a system graph. It gives you control over connections and data interactions between subsystems. It also allows you to control the timing of events.
Subsystems are represented by nodes. Ports on those nodes represent pieces of data that are propagated or consumed. Edges between ports represent data relationships between nodes.
A system graph shouldn't be confused with a visual script representation. All nodes are user-editable C# scripts, and execution order is determined by SystemGraph's scheduler. SystemGraph drives the node lifecycle instead of Unity.
One of the benefits of using a system graph is having a graphical and hierarchical overview of the data dependencies between modules.
Node
A node is the core element that describes a module functionality and logic. The node consumes, processes, and generates information that propagates through ports to other nodes. You can implement a node either with a C# script or, for subsystems, with an embedded SystemGraph node. The node scripts have access to the whole Unity C# API.
Port
A port is the connection to a node's internal variable. The node defines the type of the port, for example, whether the variable is an integer or a floating-type variable. The node also specifies whether the port is an input port or an output port, depending on whether it can be read from or written to, respectively.
The set of ports of a node defines its interface, as a subsystem. A node can be replaced by a node with a different implementation, as long as both nodes share the same interface.
Binding
A binding exposes node field data. You can use bindings to set the value of a node field directly from the Inspector window. The node defines the type of the binding, for example, whether the underlying variable is an integer or a reference to a GameObject.
Edge
An edge connects the output port of a node to the input port of a node. It represents the data propagation between the nodes.
An output port can connect to multiple input ports, but an input port connects to at most one output port.
To connect two ports with an edge, either both ports must have the same type, or there is a port converter in your project to perform the conversion between their respective types.
For performance reasons, while the term "data propagation" is sometimes used, data isn't copied from the output port to the input port. Both ports of an edge actually reference the same underlying variable.
Property
Graph properties are the inputs and outputs of the subsystem represented by that system graph. When you use an embedded SystemGraph node to implement a subsystem inside another graph, properties become the ports of the node representing that subsystem. For top-level graphs, properties are visible in the Inspector window and can be used to configure the graph behavior.
Scheduler
The scheduler sequences the execution of nodes. The scheduler executes during the Unity Update by default, and is responsible for calling the OnTick events of synchronous nodes, according to their specified clock frequency. Frequencies higher than the Unity Update are possible, and the scheduler ensures a deterministic node execution order and frequency.
Node execution type
Nodes can be synchronous or asynchronous.
Asynchronous nodes execute when their inputs change, by registering to port ChangeEvents.
Synchronous nodes specify a clock frequency and implement an OnTick event. The scheduler is responsible for calling the OnTick events of all nodes in the graph.