Skip to content

Commit 1b332e2

Browse files
committed
Fixed math example node disconnect bug
1 parent 2e3deb6 commit 1b332e2

File tree

2 files changed

+93
-4
lines changed

2 files changed

+93
-4
lines changed

Assets/Example/Scripts/MathOperationNode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public void OnConnection(SocketInput input, IOutput output)
5555
public void OnDisconnect(SocketInput input, IOutput output)
5656
{
5757
output.ValueUpdated -= OnConnectedValueUpdated;
58-
_incomingOutputs.Add(output);
58+
_incomingOutputs.Remove(output);
5959

6060
OnConnectedValueUpdated();
6161
}

Assets/docs/documentation.md

Lines changed: 92 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,101 @@
11

22
Welcome to the RuntimeNodeEditor documentation.
33

4-
## Quick overview
4+
# Quick overview
55

66
- RuntimeNodeEditor is a unityUI based node editor and works in playmode.
77

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
1099

11100

12101

0 commit comments

Comments
 (0)