From 63808eb6a2657842b40f37a555742ac76804abd4 Mon Sep 17 00:00:00 2001 From: Thor Brigsted Date: Wed, 27 Sep 2017 22:45:28 +0200 Subject: [PATCH] Removed GetInput and GetOutput and made inputs and outputs public --- Scripts/Editor/NodeEditor.cs | 4 ++-- Scripts/Editor/NodeEditorAction.cs | 4 ++-- Scripts/Editor/NodeEditorGUI.cs | 2 +- Scripts/Node.cs | 15 ++++----------- 4 files changed, 9 insertions(+), 16 deletions(-) diff --git a/Scripts/Editor/NodeEditor.cs b/Scripts/Editor/NodeEditor.cs index 6227e6e..c49fe99 100644 --- a/Scripts/Editor/NodeEditor.cs +++ b/Scripts/Editor/NodeEditor.cs @@ -27,14 +27,14 @@ public class NodeEditor { //Inputs GUILayout.BeginVertical(); for (int i = 0; i < target.InputCount; i++) { - DrawNodePortGUI(target.GetInput(i)); + DrawNodePortGUI(target.inputs[i]); } GUILayout.EndVertical(); //Outputs GUILayout.BeginVertical(); for (int i = 0; i < target.OutputCount; i++) { - DrawNodePortGUI(target.GetOutput(i)); + DrawNodePortGUI(target.outputs[i]); } GUILayout.EndVertical(); diff --git a/Scripts/Editor/NodeEditorAction.cs b/Scripts/Editor/NodeEditorAction.cs index 808382d..9c85df8 100644 --- a/Scripts/Editor/NodeEditorAction.cs +++ b/Scripts/Editor/NodeEditorAction.cs @@ -158,7 +158,7 @@ public partial class NodeEditorWindow { NodePort newHoverPort = null; //Check all input ports for (int i = 0; i < hoveredNode.InputCount; i++) { - NodePort port = hoveredNode.GetInput(i); + NodePort port = hoveredNode.inputs[i]; //Check if port rect is available if (!portConnectionPoints.ContainsKey(port)) continue; Rect r = portConnectionPoints[port]; @@ -168,7 +168,7 @@ public partial class NodeEditorWindow { } //Check all output ports for (int i = 0; i < hoveredNode.OutputCount; i++) { - NodePort port = hoveredNode.GetOutput(i); + NodePort port = hoveredNode.outputs[i]; //Check if port rect is available if (!portConnectionPoints.ContainsKey(port)) continue; Rect r = portConnectionPoints[port]; diff --git a/Scripts/Editor/NodeEditorGUI.cs b/Scripts/Editor/NodeEditorGUI.cs index 74d9872..b52c26c 100644 --- a/Scripts/Editor/NodeEditorGUI.cs +++ b/Scripts/Editor/NodeEditorGUI.cs @@ -120,7 +120,7 @@ public partial class NodeEditorWindow { public void DrawConnections() { foreach (Node node in graph.nodes) { for (int i = 0; i < node.OutputCount; i++) { - NodePort output = node.GetOutput(i); + NodePort output = node.outputs[i]; //Needs cleanup. Null checks are ugly if (!portConnectionPoints.ContainsKey(output)) continue; diff --git a/Scripts/Node.cs b/Scripts/Node.cs index 2634453..7217c90 100644 --- a/Scripts/Node.cs +++ b/Scripts/Node.cs @@ -10,10 +10,11 @@ public abstract class Node { /// Name of the node [SerializeField] public string name = ""; [SerializeField] public NodeGraph graph; - - [SerializeField] private NodePort[] inputs = new NodePort[0]; - [SerializeField] private NodePort[] outputs = new NodePort[0]; [SerializeField] public Rect rect = new Rect(0,0,200,200); + /// Input s. It is recommended not to modify these at hand. Instead, see + [SerializeField] public NodePort[] inputs = new NodePort[0]; + /// Output s. It is recommended not to modify these at hand. Instead, see + [SerializeField] public NodePort[] outputs = new NodePort[0]; public int InputCount { get { return inputs.Length; } } public int OutputCount { get { return outputs.Length; } } @@ -44,14 +45,6 @@ public abstract class Node { return -1; } - public NodePort GetInput(int portId) { - return inputs[portId]; - } - - public NodePort GetOutput(int portId) { - return outputs[portId]; - } - public NodePort CreateNodeInput(string name, Type type) { return new NodePort(name, type, this, NodePort.IO.Input); }