mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-21 01:36:03 +08:00
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.
23 lines
774 B
C#
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;
|
|
}
|
|
}
|