1
0
mirror of https://github.com/Siccity/xNode.git synced 2025-12-20 01:06:01 +08:00
xNode/Example/Nodes/ExampleNodeBase.cs
Thor Brigsted 5e68b6bcdc Big update.
Removal of scripts now also clears dependant nodes, to avoid null objects.
NodePorts now support fallback values.
UI Changes.
node.graph is now serialized as well.
2017-10-14 16:19:24 +02:00

23 lines
774 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public abstract class ExampleNodeBase : Node {
public float GetInputFloat(string fieldName) {
float result = 0f;
NodePort port = GetInputByFieldName(fieldName);
if (port == null) return result;
int connectionCount = port.ConnectionCount;
for (int i = 0; i < connectionCount; i++) {
NodePort connection = port.GetConnection(i);
if (connection == null) continue;
object obj = connection.GetValue();
if (obj == null) continue;
if (connection.type == typeof(int)) result += (int)obj;
else if (connection.type == typeof(float)) result += (float)obj;
}
return result;
}
}