mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-20 17:26:02 +08:00
Improved null handling
This commit is contained in:
parent
b9e06be096
commit
eaeca48f69
@ -116,7 +116,7 @@ public partial class NodeEditorWindow {
|
|||||||
public void DrawConnections() {
|
public void DrawConnections() {
|
||||||
foreach (Node node in graph.nodes) {
|
foreach (Node node in graph.nodes) {
|
||||||
//If a null node is found, return. This can happen if the nodes associated script is deleted. It is currently not possible in Unity to delete a null asset.
|
//If a null node is found, return. This can happen if the nodes associated script is deleted. It is currently not possible in Unity to delete a null asset.
|
||||||
if (node == null) return;
|
if (node == null) continue;
|
||||||
for (int i = 0; i < node.OutputCount; i++) {
|
for (int i = 0; i < node.OutputCount; i++) {
|
||||||
NodePort output = node.outputs[i];
|
NodePort output = node.outputs[i];
|
||||||
|
|
||||||
@ -126,8 +126,9 @@ public partial class NodeEditorWindow {
|
|||||||
for (int k = 0; k < output.ConnectionCount; k++) {
|
for (int k = 0; k < output.ConnectionCount; k++) {
|
||||||
|
|
||||||
NodePort input = output.GetConnection(k);
|
NodePort input = output.GetConnection(k);
|
||||||
if (input == null) return; //If a script has been updated and the port doesn't exist, it is removed and null is returned. If this happens, return.
|
if (input == null) continue; //If a script has been updated and the port doesn't exist, it is removed and null is returned. If this happens, return.
|
||||||
if (!_portConnectionPoints.ContainsKey(input)) return;
|
if (!input.IsConnectedTo(output)) input.Connect(output);
|
||||||
|
if (!_portConnectionPoints.ContainsKey(input)) continue;
|
||||||
Vector2 to = _portConnectionPoints[input].center;
|
Vector2 to = _portConnectionPoints[input].center;
|
||||||
DrawConnection(from, to, NodeEditorPreferences.GetTypeColor(output.type));
|
DrawConnection(from, to, NodeEditorPreferences.GetTypeColor(output.type));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -145,7 +145,7 @@ public class NodePort {
|
|||||||
if (direction == port.direction) { Debug.LogWarning("Cannot connect two " + (direction == IO.Input ? "input" : "output") + " connections"); return; }
|
if (direction == port.direction) { Debug.LogWarning("Cannot connect two " + (direction == IO.Input ? "input" : "output") + " connections"); return; }
|
||||||
connections.Add(new PortConnection(port));
|
connections.Add(new PortConnection(port));
|
||||||
if (port.connections == null) port.connections = new List<PortConnection>();
|
if (port.connections == null) port.connections = new List<PortConnection>();
|
||||||
port.connections.Add(new PortConnection(this));
|
if (!port.IsConnectedTo(this)) port.connections.Add(new PortConnection(this));
|
||||||
node.OnCreateConnection(this, port);
|
node.OnCreateConnection(this, port);
|
||||||
port.node.OnCreateConnection(this, port);
|
port.node.OnCreateConnection(this, port);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user