mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-20 09:16:01 +08:00
Big update: Warning: Updating to this commit will break all node connections.
Internal NodePorts now uses dicts instead of lists. This is faster and more manageable. Added instance ports. Added Node.Ports, Node.Outputs, Node.Inputs, Node.InstanceOutputs, Node.InstanceInputs Changed public GetInputByFieldName to GetInputValue and GetInputPort
This commit is contained in:
parent
028c481a9d
commit
d3bb36fe0e
@ -3,7 +3,7 @@
|
||||
[Input(ShowBackingValue.Never)] public object value;
|
||||
|
||||
public override object GetValue(NodePort port) {
|
||||
return GetInputByFieldName<object>("value", value);
|
||||
return GetInputValue<object>("value", value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,8 +15,8 @@
|
||||
public override object GetValue(NodePort port) {
|
||||
|
||||
// Get new a and b values from input connections. Fallback to field values if input is not connected
|
||||
float a = GetInputByFieldName<float>("a", this.a);
|
||||
float b = GetInputByFieldName<float>("b", this.b);
|
||||
float a = GetInputValue<float>("a", this.a);
|
||||
float b = GetInputValue<float>("b", this.b);
|
||||
|
||||
// After you've gotten your input values, you can perform your calculations and return a value
|
||||
if (port.fieldName == "result")
|
||||
|
||||
@ -6,9 +6,9 @@ namespace BasicNodes {
|
||||
[Output] public Vector3 vector;
|
||||
|
||||
public override object GetValue(NodePort port) {
|
||||
float x = GetInputByFieldName<float>("x", this.x);
|
||||
float y = GetInputByFieldName<float>("y", this.y);
|
||||
float z = GetInputByFieldName<float>("z", this.z);
|
||||
float x = GetInputValue<float>("x", this.x);
|
||||
float y = GetInputValue<float>("y", this.y);
|
||||
float z = GetInputValue<float>("z", this.z);
|
||||
return new Vector3(x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@ public class NodeEditor {
|
||||
|
||||
/// <summary> Draws standard field editors for all public fields </summary>
|
||||
protected virtual void OnBodyGUI() {
|
||||
string[] excludes = { "m_Script", "graph", "position", "inputs", "outputs" };
|
||||
string[] excludes = { "m_Script", "graph", "position", "ports" };
|
||||
portPositions = new Dictionary<NodePort, Vector2>();
|
||||
|
||||
SerializedProperty iterator = serializedObject.GetIterator();
|
||||
|
||||
@ -117,9 +117,8 @@ public partial class NodeEditorWindow {
|
||||
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 (node == null) continue;
|
||||
for (int i = 0; i < node.OutputCount; i++) {
|
||||
NodePort output = node.GetOutput(i);
|
||||
|
||||
foreach(NodePort output in node.Outputs) {
|
||||
//Needs cleanup. Null checks are ugly
|
||||
if (!portConnectionPoints.ContainsKey(output)) continue;
|
||||
Vector2 from = _portConnectionPoints[output].center;
|
||||
@ -206,20 +205,18 @@ public partial class NodeEditorWindow {
|
||||
|
||||
//Check if we are hovering any of this nodes ports
|
||||
//Check input ports
|
||||
for (int i = 0; i < node.InputCount; i++) {
|
||||
NodePort port = node.GetInput(i);
|
||||
foreach(NodePort input in node.Inputs) {
|
||||
//Check if port rect is available
|
||||
if (!portConnectionPoints.ContainsKey(port)) continue;
|
||||
Rect r = GridToWindowRect(portConnectionPoints[port]);
|
||||
if (r.Contains(mousePos)) hoveredPort = port;
|
||||
if (!portConnectionPoints.ContainsKey(input)) continue;
|
||||
Rect r = GridToWindowRect(portConnectionPoints[input]);
|
||||
if (r.Contains(mousePos)) hoveredPort = input;
|
||||
}
|
||||
//Check all output ports
|
||||
for (int i = 0; i < node.OutputCount; i++) {
|
||||
NodePort port = node.GetOutput(i);
|
||||
foreach(NodePort output in node.Outputs) {
|
||||
//Check if port rect is available
|
||||
if (!portConnectionPoints.ContainsKey(port)) continue;
|
||||
Rect r = GridToWindowRect(portConnectionPoints[port]);
|
||||
if (r.Contains(mousePos)) hoveredPort = port;
|
||||
if (!portConnectionPoints.ContainsKey(output)) continue;
|
||||
Rect r = GridToWindowRect(portConnectionPoints[output]);
|
||||
if (r.Contains(mousePos)) hoveredPort = output;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@ public static class NodeEditorGUILayout {
|
||||
public static void PropertyField(SerializedProperty property, bool includeChildren = true) {
|
||||
if (property == null) throw new NullReferenceException();
|
||||
Node node = property.serializedObject.targetObject as Node;
|
||||
NodePort port = node.GetPortByFieldName(property.name);
|
||||
NodePort port = node.GetPort(property.name);
|
||||
|
||||
float temp_labelWidth = EditorGUIUtility.labelWidth;
|
||||
|
||||
|
||||
@ -35,6 +35,7 @@ public static class NodeEditorUtilities {
|
||||
|
||||
/// <summary> Turns camelCaseString into Camel Case String </summary>
|
||||
public static string PrettifyCamelCase(this string camelCase) {
|
||||
if (string.IsNullOrEmpty(camelCase)) return "";
|
||||
string s = System.Text.RegularExpressions.Regex.Replace(camelCase, "([A-Z])", " $1", System.Text.RegularExpressions.RegexOptions.Compiled).Trim();
|
||||
return char.ToUpper(s[0]) + s.Substring(1);
|
||||
}
|
||||
|
||||
153
Scripts/Node.cs
153
Scripts/Node.cs
@ -14,75 +14,101 @@ public abstract class Node : ScriptableObject {
|
||||
Always
|
||||
}
|
||||
|
||||
/// <summary> Iterate over all ports on this node. </summary>
|
||||
public IEnumerable<NodePort> Ports { get { foreach (NodePort port in ports.Values) yield return port; } }
|
||||
/// <summary> Iterate over all outputs on this node. </summary>
|
||||
public IEnumerable<NodePort> Outputs { get { foreach (NodePort port in Ports) { if (port.direction == NodePort.IO.Output) yield return port; } } }
|
||||
/// <summary> Iterate over all inputs on this node. </summary>
|
||||
public IEnumerable<NodePort> Inputs { get { foreach (NodePort port in Ports) { if (port.direction == NodePort.IO.Input) yield return port; } } }
|
||||
/// <summary> Iterate over all instance outputs on this node. </summary>
|
||||
public IEnumerable<NodePort> InstanceOutputs { get { foreach (NodePort port in Ports) { if (port.direction == NodePort.IO.Input) yield return port; } } }
|
||||
/// <summary> Iterate over all instance inputs on this node. </summary>
|
||||
public IEnumerable<NodePort> InstanceInputs { get { foreach (NodePort port in Ports) { if (port.direction == NodePort.IO.Input) yield return port; } } }
|
||||
/// <summary> Parent <see cref="NodeGraph"/> </summary>
|
||||
[SerializeField] public NodeGraph graph;
|
||||
/// <summary> Position on the <see cref="NodeGraph"/> </summary>
|
||||
[SerializeField] public Vector2 position;
|
||||
/// <summary> Input <see cref="NodePort"/>s. It is recommended not to modify these at hand. Instead, see <see cref="InputAttribute"/> </summary>
|
||||
[SerializeField] private List<NodePort> inputs = new List<NodePort>();
|
||||
/// <summary> Output <see cref="NodePort"/>s. It is recommended not to modify these at hand. Instead, see <see cref="OutputAttribute"/> </summary>
|
||||
[SerializeField] private List<NodePort> outputs = new List<NodePort>();
|
||||
/// <summary> Additional instance-specific inputs. </summary>
|
||||
[SerializeField] public List<NodePort> instanceInputs = new List<NodePort>();
|
||||
/// <summary> Additional instance-specific outputs. </summary>
|
||||
[SerializeField] public List<NodePort> instanceOutputs = new List<NodePort>();
|
||||
|
||||
public int InputCount { get { return inputs.Count; } }
|
||||
public int OutputCount { get { return outputs.Count; } }
|
||||
[SerializeField] private NodePortDictionary ports = new NodePortDictionary();
|
||||
|
||||
protected void OnEnable() {
|
||||
NodeDataCache.UpdatePorts(this, inputs, outputs);
|
||||
NodeDataCache.UpdatePorts(this, ports);
|
||||
Init();
|
||||
}
|
||||
|
||||
/// <summary> Initialize node. Called on creation. </summary>
|
||||
protected virtual void Init() { name = GetType().Name; }
|
||||
|
||||
/// <summary> Checks all connections for invalid references, and removes them. </summary>
|
||||
public void VerifyConnections() {
|
||||
for (int i = 0; i < InputCount; i++) {
|
||||
inputs[i].VerifyConnections();
|
||||
}
|
||||
for (int i = 0; i < OutputCount; i++) {
|
||||
outputs[i].VerifyConnections();
|
||||
foreach (NodePort port in Ports) port.VerifyConnections();
|
||||
}
|
||||
|
||||
#region Instance Ports
|
||||
/// <summary> Returns input port at index </summary>
|
||||
public NodePort AddInstanceInput(Type type, string fieldName = null) {
|
||||
return AddInstancePort(type, NodePort.IO.Input, fieldName);
|
||||
}
|
||||
|
||||
/// <summary> Returns input port at index </summary>
|
||||
public NodePort GetInput(int i) {
|
||||
return inputs[i];
|
||||
public NodePort AddInstanceOutput(Type type, string fieldName = null) {
|
||||
return AddInstancePort(type, NodePort.IO.Output, fieldName);
|
||||
}
|
||||
|
||||
/// <summary> Returns output port at index. </summary>
|
||||
public NodePort GetOutput(int i) {
|
||||
return outputs[i];
|
||||
private NodePort AddInstancePort(Type type, NodePort.IO direction, string fieldName = null) {
|
||||
if (fieldName == null) {
|
||||
fieldName = "instanceInput_0";
|
||||
int i = 0;
|
||||
while (HasPort(fieldName)) fieldName = "instanceInput_" + (++i);
|
||||
} else if (HasPort(fieldName)) {
|
||||
Debug.LogWarning("Port '" + fieldName + "' already exists in " + name, this);
|
||||
return ports[fieldName];
|
||||
}
|
||||
NodePort port = new NodePort(fieldName, type, direction, this);
|
||||
ports.Add(fieldName, port);
|
||||
return port;
|
||||
}
|
||||
|
||||
/// <summary> Returns input or output port which matches fieldName </summary>
|
||||
public NodePort GetPortByFieldName(string fieldName) {
|
||||
NodePort port = GetOutputByFieldName(fieldName);
|
||||
if (port != null) return port;
|
||||
else return GetInputByFieldName(fieldName);
|
||||
public bool RemoveInstancePort(string fieldName) {
|
||||
NodePort port = GetPort(fieldName);
|
||||
if (port == null || port.IsStatic) return false;
|
||||
ports.Remove(fieldName);
|
||||
return true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Ports
|
||||
/// <summary> Returns output port which matches fieldName </summary>
|
||||
public NodePort GetOutputPort(string fieldName) {
|
||||
NodePort port = GetPort(fieldName);
|
||||
if (port == null || port.direction != NodePort.IO.Output) return null;
|
||||
else return port;
|
||||
}
|
||||
|
||||
/// <summary> Returns output port which matches fieldName. Returns null if none found. </summary>
|
||||
public NodePort GetOutputByFieldName(string fieldName) {
|
||||
for (int i = 0; i < OutputCount; i++) {
|
||||
if (outputs[i].fieldName == fieldName) return outputs[i];
|
||||
}
|
||||
return null;
|
||||
/// <summary> Returns input port which matches fieldName </summary>
|
||||
public NodePort GetInputPort(string fieldName) {
|
||||
NodePort port = GetPort(fieldName);
|
||||
if (port == null || port.direction != NodePort.IO.Input) return null;
|
||||
else return port;
|
||||
}
|
||||
|
||||
/// <summary> Returns input port which matches fieldName. Returns null if none found. </summary>
|
||||
public NodePort GetInputByFieldName(string fieldName) {
|
||||
for (int i = 0; i < InputCount; i++) {
|
||||
if (inputs[i].fieldName == fieldName) return inputs[i];
|
||||
}
|
||||
return null;
|
||||
/// <summary> Returns port which matches fieldName </summary>
|
||||
public NodePort GetPort(string fieldName) {
|
||||
if (ports.ContainsKey(fieldName)) return ports[fieldName];
|
||||
else return null;
|
||||
}
|
||||
|
||||
public bool HasPort(string fieldName) {
|
||||
return ports.ContainsKey(fieldName);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Inputs/Outputs
|
||||
/// <summary> Return input value for a specified port. Returns fallback value if no ports are connected </summary>
|
||||
/// <param name="fieldName">Field name of requested input port</param>
|
||||
/// <param name="fallback">If no ports are connected, this value will be returned</param>
|
||||
public T GetInputByFieldName<T>(string fieldName, T fallback = default(T)) {
|
||||
NodePort port = GetInputByFieldName(fieldName);
|
||||
public T GetInputValue<T>(string fieldName, T fallback = default(T)) {
|
||||
NodePort port = GetPort(fieldName);
|
||||
if (port != null && port.IsConnected) return port.GetInputValue<T>();
|
||||
else return fallback;
|
||||
}
|
||||
@ -90,8 +116,8 @@ public abstract class Node : ScriptableObject {
|
||||
/// <summary> Return all input values for a specified port. Returns fallback value if no ports are connected </summary>
|
||||
/// <param name="fieldName">Field name of requested input port</param>
|
||||
/// <param name="fallback">If no ports are connected, this value will be returned</param>
|
||||
public T[] GetInputsByFieldName<T>(string fieldName, params T[] fallback) {
|
||||
NodePort port = GetInputByFieldName(fieldName);
|
||||
public T[] GetInputValues<T>(string fieldName, params T[] fallback) {
|
||||
NodePort port = GetPort(fieldName);
|
||||
if (port != null && port.IsConnected) return port.GetInputValues<T>();
|
||||
else return fallback;
|
||||
}
|
||||
@ -102,9 +128,7 @@ public abstract class Node : ScriptableObject {
|
||||
Debug.LogWarning("No GetValue(NodePort port) override defined for " + GetType());
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary> Initialize node. Called on creation. </summary>
|
||||
protected virtual void Init() { name = GetType().Name; }
|
||||
#endregion
|
||||
|
||||
/// <summary> Called whenever a connection is being made between two <see cref="NodePort"/>s</summary>
|
||||
/// <param name="from">Output</param> <param name="to">Input</param>
|
||||
@ -112,32 +136,51 @@ public abstract class Node : ScriptableObject {
|
||||
|
||||
/// <summary> Disconnect everything from this node </summary>
|
||||
public void ClearConnections() {
|
||||
for (int i = 0; i < inputs.Count; i++) {
|
||||
inputs[i].ClearConnections();
|
||||
}
|
||||
for (int i = 0; i < outputs.Count; i++) {
|
||||
outputs[i].ClearConnections();
|
||||
}
|
||||
foreach (NodePort port in Ports) port.ClearConnections();
|
||||
}
|
||||
|
||||
public override int GetHashCode() {
|
||||
return JsonUtility.ToJson(this).GetHashCode();
|
||||
}
|
||||
|
||||
/// <summary> Mark a serializable field as an input port. You can access this through <see cref="GetInputByFieldName(string)"/> </summary>
|
||||
/// <summary> Mark a serializable field as an input port. You can access this through <see cref="GetInput(string)"/> </summary>
|
||||
[AttributeUsage(AttributeTargets.Field, AllowMultiple = true)]
|
||||
public class InputAttribute : Attribute {
|
||||
public ShowBackingValue backingValue;
|
||||
|
||||
/// <summary> Mark a serializable field as an input port. You can access this through <see cref="GetInputByFieldName(string)"/> </summary>
|
||||
/// <summary> Mark a serializable field as an input port. You can access this through <see cref="GetInput(string)"/> </summary>
|
||||
/// <param name="backingValue">Should we display the backing value for this port as an editor field? </param>
|
||||
public InputAttribute(ShowBackingValue backingValue = ShowBackingValue.Unconnected) { this.backingValue = backingValue; }
|
||||
}
|
||||
|
||||
/// <summary> Mark a serializable field as an output port. You can access this through <see cref="GetOutputByFieldName(string)"/> </summary>
|
||||
/// <summary> Mark a serializable field as an output port. You can access this through <see cref="GetOutput(string)"/> </summary>
|
||||
[AttributeUsage(AttributeTargets.Field, AllowMultiple = true)]
|
||||
public class OutputAttribute : Attribute {
|
||||
/// <summary> Mark a serializable field as an output port. You can access this through <see cref="GetOutputByFieldName(string)"/> </summary>
|
||||
/// <summary> Mark a serializable field as an output port. You can access this through <see cref="GetOutput(string)"/> </summary>
|
||||
public OutputAttribute() { }
|
||||
}
|
||||
|
||||
[Serializable] private class NodePortDictionary : Dictionary<string, NodePort>, ISerializationCallbackReceiver {
|
||||
[SerializeField] private List<string> keys = new List<string>();
|
||||
[SerializeField] private List<NodePort> values = new List<NodePort>();
|
||||
|
||||
public void OnBeforeSerialize() {
|
||||
keys.Clear();
|
||||
values.Clear();
|
||||
foreach (KeyValuePair<string, NodePort> pair in this) {
|
||||
keys.Add(pair.Key);
|
||||
values.Add(pair.Value);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnAfterDeserialize() {
|
||||
this.Clear();
|
||||
|
||||
if (keys.Count != values.Count)
|
||||
throw new System.Exception(string.Format("there are {0} keys and {1} values after deserialization. Make sure that both key and value types are serializable."));
|
||||
|
||||
for (int i = 0; i < keys.Count; i++)
|
||||
this.Add(keys[i], values[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -10,46 +10,33 @@ public static class NodeDataCache {
|
||||
private static PortDataCache portDataCache;
|
||||
private static bool Initialized { get { return portDataCache != null; } }
|
||||
|
||||
/// <summary> Checks for invalid and removes them.
|
||||
/// Checks for missing ports and adds them.
|
||||
/// Checks for invalid connections and removes them. </summary>
|
||||
public static void UpdatePorts(Node node, List<NodePort> inputs, List<NodePort> outputs) {
|
||||
/// <summary> Update static ports to reflect class fields. </summary>
|
||||
public static void UpdatePorts(Node node, Dictionary<string, NodePort> ports) {
|
||||
if (!Initialized) BuildCache();
|
||||
|
||||
List<NodePort> inputPorts = new List<NodePort>();
|
||||
List<NodePort> outputPorts = new List<NodePort>();
|
||||
|
||||
Dictionary<string, NodePort> staticPorts = new Dictionary<string, NodePort>();
|
||||
System.Type nodeType = node.GetType();
|
||||
inputPorts = new List<NodePort>();
|
||||
outputPorts = new List<NodePort>();
|
||||
|
||||
if (!portDataCache.ContainsKey(nodeType)) return;
|
||||
for (int i = 0; i < portDataCache[nodeType].Count; i++) {
|
||||
if (portDataCache[nodeType][i].direction == NodePort.IO.Input) inputPorts.Add(new NodePort(portDataCache[nodeType][i], node));
|
||||
else outputPorts.Add(new NodePort(portDataCache[nodeType][i], node));
|
||||
staticPorts.Add(portDataCache[nodeType][i].fieldName, portDataCache[nodeType][i]);
|
||||
}
|
||||
|
||||
for (int i = inputs.Count - 1; i >= 0; i--) {
|
||||
int index = inputPorts.FindIndex(x => inputs[i].fieldName == x.fieldName);
|
||||
//If input nodeport does not exist, remove it
|
||||
if (index == -1) inputs.RemoveAt(i);
|
||||
//If input nodeport does exist, update it
|
||||
else inputs[i].type = inputPorts[index].type;
|
||||
// Cleanup port dict - Remove nonexisting static ports - update static port types
|
||||
foreach (NodePort port in ports.Values) {
|
||||
if (staticPorts.ContainsKey(port.fieldName)) {
|
||||
NodePort staticPort = staticPorts[port.fieldName];
|
||||
if (port.IsDynamic || port.direction != staticPort.direction) ports.Remove(port.fieldName);
|
||||
else port.type = staticPort.type;
|
||||
} else {
|
||||
ports.Remove(port.fieldName);
|
||||
}
|
||||
for (int i = outputs.Count - 1; i >= 0; i--) {
|
||||
int index = outputPorts.FindIndex(x => outputs[i].fieldName == x.fieldName);
|
||||
//If output nodeport does not exist, remove it
|
||||
if (index == -1) outputs.RemoveAt(i);
|
||||
//If output nodeport does exist, update it
|
||||
else outputs[i].type = outputPorts[index].type;
|
||||
}
|
||||
//Add
|
||||
for (int i = 0; i < inputPorts.Count; i++) {
|
||||
//If inputports contains a new port, add it
|
||||
if (!inputs.Any(x => x.fieldName == inputPorts[i].fieldName)) inputs.Add(inputPorts[i]);
|
||||
// Add missing ports
|
||||
foreach (NodePort staticPort in staticPorts.Values) {
|
||||
if (!ports.ContainsKey(staticPort.fieldName)) {
|
||||
ports.Add(staticPort.fieldName, new NodePort(staticPort, node));
|
||||
}
|
||||
for (int i = 0; i < outputPorts.Count; i++) {
|
||||
//If inputports contains a new port, add it
|
||||
if (!outputs.Any(x => x.fieldName == outputPorts[i].fieldName)) outputs.Add(outputPorts[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -20,18 +20,21 @@ public class NodePort {
|
||||
|
||||
public string fieldName { get { return _fieldName; } }
|
||||
public Node node { get { return _node; } }
|
||||
public bool IsDynamic { get { return _dynamic; } }
|
||||
public bool IsStatic { get { return !_dynamic; } }
|
||||
|
||||
[SerializeField] private Node _node;
|
||||
[SerializeField] private string _fieldName;
|
||||
[SerializeField] public Type type;
|
||||
[SerializeField] private List<PortConnection> connections = new List<PortConnection>();
|
||||
[SerializeField] private IO _direction;
|
||||
[SerializeField] private bool _dynamic;
|
||||
|
||||
/// <summary> Construct a static targetless nodeport. Used as a template. </summary>
|
||||
public NodePort(FieldInfo fieldInfo) {
|
||||
_fieldName = fieldInfo.Name;
|
||||
type = fieldInfo.FieldType;
|
||||
|
||||
_dynamic = false;
|
||||
var attribs = fieldInfo.GetCustomAttributes(false);
|
||||
for (int i = 0; i < attribs.Length; i++) {
|
||||
if (attribs[i] is Node.InputAttribute) _direction = IO.Input;
|
||||
@ -44,6 +47,7 @@ public class NodePort {
|
||||
_fieldName = nodePort._fieldName;
|
||||
type = nodePort.type;
|
||||
_direction = nodePort.direction;
|
||||
_dynamic = nodePort._dynamic;
|
||||
_node = node;
|
||||
}
|
||||
|
||||
@ -53,6 +57,7 @@ public class NodePort {
|
||||
this.type = type;
|
||||
_direction = direction;
|
||||
_node = node;
|
||||
_dynamic = true;
|
||||
}
|
||||
|
||||
/// <summary> Checks all connections for invalid references, and removes them. </summary>
|
||||
@ -60,7 +65,7 @@ public class NodePort {
|
||||
for (int i = connections.Count - 1; i >= 0; i--) {
|
||||
if (connections[i].node != null &&
|
||||
!string.IsNullOrEmpty(connections[i].fieldName) &&
|
||||
connections[i].node.GetPortByFieldName(connections[i].fieldName) != null)
|
||||
connections[i].node.GetPort(connections[i].fieldName) != null)
|
||||
continue;
|
||||
connections.RemoveAt(i);
|
||||
}
|
||||
@ -69,6 +74,7 @@ public class NodePort {
|
||||
/// <summary> Return the output value of this node through its parent nodes GetValue override method. </summary>
|
||||
/// <returns> <see cref="Node.GetValue(NodePort)"/> </returns>
|
||||
public object GetOutputValue() {
|
||||
if (direction == IO.Input) return null;
|
||||
return node.GetValue(this);
|
||||
}
|
||||
|
||||
@ -167,7 +173,7 @@ public class NodePort {
|
||||
connections.RemoveAt(i);
|
||||
return null;
|
||||
}
|
||||
NodePort port = connections[i].node.GetPortByFieldName(connections[i].fieldName);
|
||||
NodePort port = connections[i].node.GetPort(connections[i].fieldName);
|
||||
if (port == null) {
|
||||
connections.RemoveAt(i);
|
||||
return null;
|
||||
@ -218,7 +224,7 @@ public class NodePort {
|
||||
/// <summary> Returns the port that this <see cref="PortConnection"/> points to </summary>
|
||||
private NodePort GetPort() {
|
||||
if (node == null || string.IsNullOrEmpty(fieldName)) return null;
|
||||
return node.GetPortByFieldName(fieldName);
|
||||
return node.GetPort(fieldName);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user