Binding
A binding exposes node field data. You can use bindings to set internal value of a node instance directly from the inspector. Bindings are independent from SystemGraph assets, and the value set on a binding is done through an instance of the System Graph Component in the Inspector window. It doesn't serialize the value into the SystemGraph asset file. Bindings are useful when you want to bind a scene object or graph instance from a scene in your graph.
It's recommended to use bindings over properties, as they bind values directly to a node. Bindings don't rely on the lifecycle of the SystemGraph to be available. There's no requirement to create nodes and edges, or depend on propagation to set the value of a binding.
Instances of objects in a scene are normally used as bindings, while properties are mostly used as settings to be used in the graph.
Declare a binding type
To register binding types to the SystemGraph core, you must define the binding type and define an Editor to display in the Inspector window:
[RegisterBinding(typeof(Binding<SystemGraphComponent>))]
[AddComponentMenu("")]
public class SystemGraphComponentBinding: Binding<SystemGraphComponent>
{
}
#if UNITY_EDITOR
[CustomEditor(typeof(SystemGraphComponentBinding))]
public class SystemGraphComponentBindingEditor: Editor
{
// ...
}
Use a binding in a node
To use a binding in a node:
[NodeCategory("Type", "SystemGraph", NodeTick = NodeTick.Asynchronous,
Mode = NodeMode.Standard)]
public class NodeSystemGraph: NodeRuntime
{
[Binding("SystemGraphComponent Instance"), SerializeField]
public Binding<SystemGraphComponent> boundSystemGraphComponent = null;
}
Bind UI
In the SystemGraph editor, the binding is below the Node view in the SystemGraph editor. You can also find the binding in the Inspector window within the System Graph Component, as shown in the image below.