-
-
Notifications
You must be signed in to change notification settings - Fork 592
How it works
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 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 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 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 is given for free since both Node and NodeGraph derive from ScriptableObject. This means the same rules apply as in the Unity Editor.
unfinished