Skip to content

How it works

Thor Brigsted edited this page Jan 1, 2018 · 1 revision

How does it all work?

xNode exists almost entirely in editor scripts. What follows into the build is only the graphs and their nodes.

On this page I will try to explain what xNode does behind the curtain.

The Editor

The editor is the most complex part of xNode, yet it is relatively simple. It attempts to work with unity and its quirks, instead of against it. All node drawing uses standard EditorGUILayout.PropertyField, which provides free undo functionality. A lot of reflection data is cached to improve performance.

unfinished

NodeGraphs and Nodes

NodeGraphs don't do much else than contain a list of nodes and provide various ways to access them. Nodes each contain a position and a dictionary of ports and various ways to access them. Dictionary provides quick access to ports by field name.

unfinished

Node Ports

Node ports are simply pointers to other ports. Internally, the system does not differentiate between input and output ports, apart from an enum value which is set on creation. Ports do not provide any way to directly access the field value it represents, because that would require runtime reflection, and that wouldn't be very performant. Instead, it gets its input value by calling GetValue on one or more of its connected ports' nodes.

unfinished

Serialization

Serialization is given for free since both Node and NodeGraph derive from ScriptableObject. This means the same rules apply as in the Unity Editor.

unfinished

Clone this wiki locally