1
0
mirror of https://github.com/Siccity/xNode.git synced 2025-12-20 17:26:02 +08:00
xNode/Example/Nodes/ExampleNodeBase.cs
2017-10-13 20:28:40 +02:00

23 lines
765 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public 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;
}
}