1
0
mirror of https://github.com/Siccity/xNode.git synced 2025-12-20 09:16:01 +08:00
xNode/Example/Nodes/ExampleNodeBase.cs
Thor 4fcaede3b0 NodePort.GetValue changes
Removed NodePort.GetValue
Added NodePort.GetOutputValue
Added NodePort.GetInputValue
Added NodePort.GetInputValue<T>
Added NodePort.GetInputValues
Added NodePort.GetInputValues<T>
Added NodePort.TryGetInputValue<T>
2017-10-20 11:41:16 +02:00

23 lines
780 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.GetOutputValue();
if (obj == null) continue;
if (connection.type == typeof(int)) result += (int)obj;
else if (connection.type == typeof(float)) result += (float)obj;
}
return result;
}
}