|
1 | 1 |
|
2 | 2 | Welcome to the RuntimeNodeEditor documentation. |
3 | 3 |
|
4 | | -## Quick overview |
| 4 | +# Quick overview |
5 | 5 |
|
6 | 6 | - RuntimeNodeEditor is a unityUI based node editor and works in playmode. |
7 | 7 |
|
8 | | -- Socket based connections |
9 | | -- |
| 8 | +- A connection happens between a `InputSocket.cs` and `OutputSocket.cs` all derived from `Socket.cs`. |
| 9 | + |
| 10 | +- A `Node.cs` is a container for sockets. It listens connection events for its sockets. |
| 11 | + |
| 12 | +- A `NodeGraph.cs` can create nodes and draws connections between sockets. Can be serialized into json file. |
| 13 | + |
| 14 | +- `NodeEditor.cs` is a MonoBehavior class and lives in the scene. Can listen graph events. It has a simple context menu feature. |
| 15 | + |
| 16 | +- It is possible to have multiple node editors in a scene. Each editor will |
| 17 | + |
| 18 | +- Works completely event based. Integrates with unity `EventSystem` to listen pointer events for sockets, nodes and graph. |
| 19 | + |
| 20 | + |
| 21 | +# Getting started |
| 22 | + |
| 23 | +RuntimeNodeEditor is intended as a framework to work easily in a unity scene. |
| 24 | +It can be setup with a minimal configuration and its event based flow allows users to create their system on top of it. |
| 25 | + |
| 26 | +## Core concepts |
| 27 | + |
| 28 | +### Socket and Connection |
| 29 | + |
| 30 | +> `output(value)` --> connection --> `input` |
| 31 | +
|
| 32 | +A single connection happens between an input and an output socket. |
| 33 | +This is a one-direction communication from the output to input. An input may accept single or multiple connections. |
| 34 | + |
| 35 | +`InputSocket` and `OutputSocket` is implemented to work as generic sockets derived from abstract `Socket`. |
| 36 | + |
| 37 | +`OutputSocket` implements `IOutput` interface to make it easy to share and read the incoming value as an object. |
| 38 | + |
| 39 | +```c# |
| 40 | +public interface IOutput |
| 41 | +{ |
| 42 | + T GetValue<T>(); |
| 43 | + event Action ValueUpdated; |
| 44 | +} |
| 45 | +``` |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | +### Node |
| 50 | + |
| 51 | +```c# |
| 52 | +public class SampleNode : Node |
| 53 | +{ |
| 54 | + public OutputSocket myOutput; |
| 55 | +} |
| 56 | +``` |
| 57 | + |
| 58 | +A node is a hub for sockets. It registers and controlls its sockets when a connection invoked. |
| 59 | + |
| 60 | + |
| 61 | +When a connection succeeded, input socket's owner node invokes the `OnConnectionEvent` event. |
| 62 | + |
| 63 | + |
| 64 | +```c# |
| 65 | +public class SampleNode : Node |
| 66 | +{ |
| 67 | + ... |
| 68 | + |
| 69 | + // fields |
| 70 | + // ui objects fields |
| 71 | + // input or output sockets |
| 72 | +
|
| 73 | + ... |
| 74 | + |
| 75 | + public override void Setup() |
| 76 | + { |
| 77 | + // setup your custom node here |
| 78 | +
|
| 79 | + OnConnectionEvent += OnConnection; |
| 80 | + OnDisconnectEvent += OnDisconnect; |
| 81 | + } |
| 82 | + |
| 83 | + public void OnConnection(SocketInput input, IOutput output) |
| 84 | + { |
| 85 | + output.ValueUpdated += OnConnectedValueUpdated; |
| 86 | + } |
| 87 | + |
| 88 | + public void OnDisconnect(SocketInput input, IOutput output) |
| 89 | + { |
| 90 | + output.ValueUpdated -= OnConnectedValueUpdated; |
| 91 | + } |
| 92 | +} |
| 93 | +``` |
| 94 | + |
| 95 | + |
| 96 | +### NodeGraph |
| 97 | +### NodeEditor |
| 98 | +### ContextMenu |
10 | 99 |
|
11 | 100 |
|
12 | 101 |
|
|
0 commit comments