mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-20 09:16:01 +08:00
Bug fixes
This commit is contained in:
parent
cfccc4f89a
commit
8eff75fa7f
@ -127,7 +127,7 @@ public partial class NodeEditorWindow {
|
||||
if (!_portConnectionPoints.ContainsKey(draggedOutput)) return;
|
||||
Vector2 from = _portConnectionPoints[draggedOutput].center;
|
||||
Vector2 to = draggedOutputTarget != null ? portConnectionPoints[draggedOutputTarget].center : WindowToGridPosition(Event.current.mousePosition);
|
||||
Color col = NodeEditorPreferences.GetTypeColor(draggedOutput.type);
|
||||
Color col = NodeEditorPreferences.GetTypeColor(draggedOutput.ValueType);
|
||||
col.a = 0.6f;
|
||||
DrawConnection(from, to, col);
|
||||
}
|
||||
|
||||
@ -129,7 +129,7 @@ public partial class NodeEditorWindow {
|
||||
if (!input.IsConnectedTo(output)) input.Connect(output);
|
||||
if (!_portConnectionPoints.ContainsKey(input)) continue;
|
||||
Vector2 to = _portConnectionPoints[input].center;
|
||||
DrawConnection(from, to, NodeEditorPreferences.GetTypeColor(output.type));
|
||||
DrawConnection(from, to, NodeEditorPreferences.GetTypeColor(output.ValueType));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -235,7 +235,7 @@ public partial class NodeEditorWindow {
|
||||
|
||||
private void DrawTooltip() {
|
||||
if (hoveredPort != null) {
|
||||
Type type = hoveredPort.type;
|
||||
Type type = hoveredPort.ValueType;
|
||||
GUIContent content = new GUIContent();
|
||||
content.text = TypeToString(type);
|
||||
Vector2 size = NodeEditorResources.styles.tooltip.CalcSize(content);
|
||||
@ -246,6 +246,7 @@ public partial class NodeEditorWindow {
|
||||
}
|
||||
|
||||
private string TypeToString(Type type) {
|
||||
if (type == null) return "null";
|
||||
if (type == typeof(float)) return "float";
|
||||
else if (type == typeof(int)) return "int";
|
||||
else if (type == typeof(long)) return "long";
|
||||
@ -276,6 +277,6 @@ public partial class NodeEditorWindow {
|
||||
int i = s.IndexOf('[');
|
||||
return s.Substring(0,i) + "["+rank+"]" + s.Substring(i);
|
||||
}
|
||||
} else return hoveredPort.type.ToString();
|
||||
} else return hoveredPort.ValueType.ToString();
|
||||
}
|
||||
}
|
||||
@ -38,7 +38,7 @@ public static class NodeEditorGUILayout {
|
||||
|
||||
rect.size = new Vector2(16, 16);
|
||||
|
||||
DrawPortHandle(rect, port.type);
|
||||
DrawPortHandle(rect, port.ValueType);
|
||||
|
||||
// Register the handle position
|
||||
Vector2 portPos = rect.center;
|
||||
|
||||
@ -74,6 +74,7 @@ public abstract class Node : ScriptableObject {
|
||||
public bool RemoveInstancePort(string fieldName) {
|
||||
NodePort port = GetPort(fieldName);
|
||||
if (port == null || port.IsStatic) return false;
|
||||
port.ClearConnections();
|
||||
ports.Remove(fieldName);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -23,14 +23,12 @@ public static class NodeDataCache {
|
||||
}
|
||||
|
||||
// Cleanup port dict - Remove nonexisting static ports - update static port types
|
||||
foreach (NodePort port in ports.Values) {
|
||||
foreach (NodePort port in ports.Values.ToList()) {
|
||||
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);
|
||||
}
|
||||
else port.ValueType = staticPort.ValueType;
|
||||
} else if (port.IsStatic) ports.Remove(port.fieldName);
|
||||
}
|
||||
// Add missing ports
|
||||
foreach (NodePort staticPort in staticPorts.Values) {
|
||||
|
||||
@ -103,6 +103,11 @@ public class NodePort {
|
||||
object[] objs = new object[ConnectionCount];
|
||||
for (int i = 0; i < ConnectionCount; i++) {
|
||||
NodePort connectedPort = connections[i].Port;
|
||||
if (connectedPort == null) { // if we happen to find a null port, remove it and look again
|
||||
connections.RemoveAt(i);
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
objs[i] = connectedPort.GetOutputValue();
|
||||
}
|
||||
return objs;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user