diff --git a/Scripts/Attributes/NodeEnum.cs b/Scripts/Attributes/NodeEnum.cs
index 9cdaef4..92d5cfb 100644
--- a/Scripts/Attributes/NodeEnum.cs
+++ b/Scripts/Attributes/NodeEnum.cs
@@ -1,5 +1,8 @@
using UnityEngine;
-/// Draw enums correctly within nodes. Without it, enums show up at the wrong positions.
-/// Enums with this attribute are not detected by EditorGui.ChangeCheck due to waiting before executing
-public class NodeEnumAttribute : PropertyAttribute { }
\ No newline at end of file
+namespace Attributes
+{
+ /// Draw enums correctly within nodes. Without it, enums show up at the wrong positions.
+ /// Enums with this attribute are not detected by EditorGui.ChangeCheck due to waiting before executing
+ public class NodeEnumAttribute : PropertyAttribute { }
+}
\ No newline at end of file
diff --git a/Scripts/Attributes/PortTypeOverrideAttribute.cs b/Scripts/Attributes/PortTypeOverrideAttribute.cs
index 316ca2d..9fd5be7 100644
--- a/Scripts/Attributes/PortTypeOverrideAttribute.cs
+++ b/Scripts/Attributes/PortTypeOverrideAttribute.cs
@@ -1,12 +1,16 @@
using System;
-/// Overrides the ValueType of the Port, to have a ValueType different from the type of its serializable field
-/// Especially useful in Dynamic Port Lists to create Value-Port Pairs with different type.
-[AttributeUsage(AttributeTargets.Field)]
-public class PortTypeOverrideAttribute : Attribute {
- public Type type;
- /// Overrides the ValueType of the Port
- /// ValueType of the Port
- public PortTypeOverrideAttribute(Type type) {
- this.type = type;
+
+namespace Attributes
+{
+ /// Overrides the ValueType of the Port, to have a ValueType different from the type of its serializable field
+ /// Especially useful in Dynamic Port Lists to create Value-Port Pairs with different type.
+ [AttributeUsage(AttributeTargets.Field)]
+ public class PortTypeOverrideAttribute : Attribute {
+ public Type type;
+ /// Overrides the ValueType of the Port
+ /// ValueType of the Port
+ public PortTypeOverrideAttribute(Type type) {
+ this.type = type;
+ }
}
}
diff --git a/Scripts/Editor/Drawers/NodeEnumDrawer.cs b/Scripts/Editor/Drawers/NodeEnumDrawer.cs
index 8aa748c..0319820 100644
--- a/Scripts/Editor/Drawers/NodeEnumDrawer.cs
+++ b/Scripts/Editor/Drawers/NodeEnumDrawer.cs
@@ -1,9 +1,9 @@
using System;
using System.Collections;
using System.Collections.Generic;
+using Attributes;
using UnityEditor;
using UnityEngine;
-using XNode;
using XNodeEditor;
namespace XNodeEditor {
diff --git a/Scripts/Editor/GraphAndNodeEditor.cs b/Scripts/Editor/GraphAndNodeEditor.cs
index 6859855..6bbb865 100644
--- a/Scripts/Editor/GraphAndNodeEditor.cs
+++ b/Scripts/Editor/GraphAndNodeEditor.cs
@@ -8,7 +8,7 @@ using Sirenix.Utilities.Editor;
namespace XNodeEditor {
/// Override graph inspector to show an 'Open Graph' button at the top
- [CustomEditor(typeof(XNode.NodeGraph), true)]
+ [CustomEditor(typeof(NodeGraph), true)]
#if ODIN_INSPECTOR
public class GlobalGraphEditor : OdinEditor {
public override void OnInspectorGUI() {
@@ -25,7 +25,7 @@ namespace XNodeEditor {
serializedObject.Update();
if (GUILayout.Button("Edit graph", GUILayout.Height(40))) {
- NodeEditorWindow.Open(serializedObject.targetObject as XNode.NodeGraph);
+ NodeEditorWindow.Open(serializedObject.targetObject as NodeGraph);
}
GUILayout.Space(EditorGUIUtility.singleLineHeight);
@@ -38,7 +38,7 @@ namespace XNodeEditor {
}
#endif
- [CustomEditor(typeof(XNode.Node), true)]
+ [CustomEditor(typeof(Node), true)]
#if ODIN_INSPECTOR
public class GlobalNodeEditor : OdinEditor {
public override void OnInspectorGUI() {
@@ -58,7 +58,7 @@ namespace XNodeEditor {
if (GUILayout.Button("Edit graph", GUILayout.Height(40))) {
SerializedProperty graphProp = serializedObject.FindProperty("graph");
- NodeEditorWindow w = NodeEditorWindow.Open(graphProp.objectReferenceValue as XNode.NodeGraph);
+ NodeEditorWindow w = NodeEditorWindow.Open(graphProp.objectReferenceValue as NodeGraph);
w.Home(); // Focus selected node
}
diff --git a/Scripts/Editor/GraphRenameFixAssetProcessor.cs b/Scripts/Editor/GraphRenameFixAssetProcessor.cs
index 264e8b1..cf5ec93 100644
--- a/Scripts/Editor/GraphRenameFixAssetProcessor.cs
+++ b/Scripts/Editor/GraphRenameFixAssetProcessor.cs
@@ -1,13 +1,12 @@
using UnityEditor;
-using XNode;
namespace XNodeEditor {
///
/// This asset processor resolves an issue with the new v2 AssetDatabase system present on 2019.3 and later. When
- /// renaming a asset, it appears that sometimes the v2 AssetDatabase will swap which asset
- /// is the main asset (present at top level) between the and one of its
+ /// renaming a asset, it appears that sometimes the v2 AssetDatabase will swap which asset
+ /// is the main asset (present at top level) between the and one of its
/// sub-assets. As a workaround until Unity fixes this, this asset processor checks all renamed assets and if it
- /// finds a case where a has been made the main asset it will swap it back to being a sub-asset
+ /// finds a case where a has been made the main asset it will swap it back to being a sub-asset
/// and rename the node to the default name for that node type.
///
internal sealed class GraphRenameFixAssetProcessor : AssetPostprocessor {
diff --git a/Scripts/Editor/Internal/RerouteReference.cs b/Scripts/Editor/Internal/RerouteReference.cs
index 4e21130..995b1dd 100644
--- a/Scripts/Editor/Internal/RerouteReference.cs
+++ b/Scripts/Editor/Internal/RerouteReference.cs
@@ -2,11 +2,11 @@
namespace XNodeEditor.Internal {
public struct RerouteReference {
- public XNode.NodePort port;
+ public NodePort port;
public int connectionIndex;
public int pointIndex;
- public RerouteReference(XNode.NodePort port, int connectionIndex, int pointIndex) {
+ public RerouteReference(NodePort port, int connectionIndex, int pointIndex) {
this.port = port;
this.connectionIndex = connectionIndex;
this.pointIndex = pointIndex;
diff --git a/Scripts/Editor/NodeEditor.cs b/Scripts/Editor/NodeEditor.cs
index 8522fc0..4c57611 100644
--- a/Scripts/Editor/NodeEditor.cs
+++ b/Scripts/Editor/NodeEditor.cs
@@ -14,12 +14,12 @@ using GenericMenu = XNodeEditor.AdvancedGenericMenu;
namespace XNodeEditor {
/// Base class to derive custom Node editors from. Use this to create your own custom inspectors and editors for your nodes.
- [CustomNodeEditor(typeof(XNode.Node))]
- public class NodeEditor : XNodeEditor.Internal.NodeEditorBase {
+ [CustomNodeEditor(typeof(Node))]
+ public class NodeEditor : XNodeEditor.Internal.NodeEditorBase {
/// Fires every whenever a node was modified through the editor
- public static Action onUpdateNode;
- public readonly static Dictionary portPositions = new Dictionary();
+ public static Action onUpdateNode;
+ public readonly static Dictionary portPositions = new Dictionary();
#if ODIN_INSPECTOR
protected internal static bool inNodeEditor = false;
@@ -82,7 +82,7 @@ namespace XNodeEditor {
#endif
// Iterate through dynamic ports and draw them in the order in which they are serialized
- foreach (XNode.NodePort dynamicPort in target.DynamicPorts) {
+ foreach (NodePort dynamicPort in target.DynamicPorts) {
if (NodeEditorGUILayout.IsDynamicPortListPort(dynamicPort)) continue;
NodeEditorGUILayout.PortField(dynamicPort);
}
@@ -136,8 +136,8 @@ namespace XNodeEditor {
public virtual void AddContextMenuItems(GenericMenu menu) {
bool canRemove = true;
// Actions if only one node is selected
- if (Selection.objects.Length == 1 && Selection.activeObject is XNode.Node) {
- XNode.Node node = Selection.activeObject as XNode.Node;
+ if (Selection.objects.Length == 1 && Selection.activeObject is Node) {
+ Node node = Selection.activeObject as Node;
menu.AddItem(new GUIContent("Move To Top"), false, () => NodeEditorWindow.current.MoveNodeToTop(node));
menu.AddItem(new GUIContent("Rename"), false, NodeEditorWindow.current.RenameSelectedNode);
@@ -152,8 +152,8 @@ namespace XNodeEditor {
else menu.AddItem(new GUIContent("Remove"), false, null);
// Custom sctions if only one node is selected
- if (Selection.objects.Length == 1 && Selection.activeObject is XNode.Node) {
- XNode.Node node = Selection.activeObject as XNode.Node;
+ if (Selection.objects.Length == 1 && Selection.activeObject is Node) {
+ Node node = Selection.activeObject as Node;
menu.AddCustomContextMenuItems(node);
}
}
@@ -171,7 +171,7 @@ namespace XNodeEditor {
[AttributeUsage(AttributeTargets.Class)]
public class CustomNodeEditorAttribute : Attribute,
- XNodeEditor.Internal.NodeEditorBase.INodeEditorAttrib {
+ XNodeEditor.Internal.NodeEditorBase.INodeEditorAttrib {
private Type inspectedType;
/// Tells a NodeEditor which Node type it is an editor for
/// Type that this editor can edit
diff --git a/Scripts/Editor/NodeEditorAction.cs b/Scripts/Editor/NodeEditorAction.cs
index a9147f2..fb81194 100644
--- a/Scripts/Editor/NodeEditorAction.cs
+++ b/Scripts/Editor/NodeEditorAction.cs
@@ -15,7 +15,7 @@ namespace XNodeEditor {
public static bool isPanning { get; private set; }
public static Vector2[] dragOffset;
- public static XNode.Node[] copyBuffer = null;
+ public static Node[] copyBuffer = null;
public bool IsDraggingPort { get { return draggedOutput != null; } }
public bool IsHoveringPort { get { return hoveredPort != null; } }
@@ -23,17 +23,17 @@ namespace XNodeEditor {
public bool IsHoveringReroute { get { return hoveredReroute.port != null; } }
/// Return the dragged port or null if not exist
- public XNode.NodePort DraggedOutputPort { get { XNode.NodePort result = draggedOutput; return result; } }
+ public NodePort DraggedOutputPort { get { NodePort result = draggedOutput; return result; } }
/// Return the Hovered port or null if not exist
- public XNode.NodePort HoveredPort { get { XNode.NodePort result = hoveredPort; return result; } }
+ public NodePort HoveredPort { get { NodePort result = hoveredPort; return result; } }
/// Return the Hovered node or null if not exist
- public XNode.Node HoveredNode { get { XNode.Node result = hoveredNode; return result; } }
+ public Node HoveredNode { get { Node result = hoveredNode; return result; } }
- private XNode.Node hoveredNode = null;
- [NonSerialized] public XNode.NodePort hoveredPort = null;
- [NonSerialized] private XNode.NodePort draggedOutput = null;
- [NonSerialized] private XNode.NodePort draggedOutputTarget = null;
- [NonSerialized] private XNode.NodePort autoConnectOutput = null;
+ private Node hoveredNode = null;
+ [NonSerialized] public NodePort hoveredPort = null;
+ [NonSerialized] private NodePort draggedOutput = null;
+ [NonSerialized] private NodePort draggedOutputTarget = null;
+ [NonSerialized] private NodePort autoConnectOutput = null;
[NonSerialized] private List draggedOutputReroutes = new List();
private RerouteReference hoveredReroute = new RerouteReference();
@@ -91,8 +91,8 @@ namespace XNodeEditor {
Vector2 mousePos = WindowToGridPosition(e.mousePosition);
// Move selected nodes with offset
for (int i = 0; i < Selection.objects.Length; i++) {
- if (Selection.objects[i] is XNode.Node) {
- XNode.Node node = Selection.objects[i] as XNode.Node;
+ if (Selection.objects[i] is Node) {
+ Node node = Selection.objects[i] as Node;
Undo.RecordObject(node, "Moved Node");
Vector2 initial = node.position;
node.position = mousePos + dragOffset[i];
@@ -104,7 +104,7 @@ namespace XNodeEditor {
// Offset portConnectionPoints instantly if a node is dragged so they aren't delayed by a frame.
Vector2 offset = node.position - initial;
if (offset.sqrMagnitude > 0) {
- foreach (XNode.NodePort output in node.Outputs) {
+ foreach (NodePort output in node.Outputs) {
Rect rect;
if (portConnectionPoints.TryGetValue(output, out rect)) {
rect.position += offset;
@@ -112,7 +112,7 @@ namespace XNodeEditor {
}
}
- foreach (XNode.NodePort input in node.Inputs) {
+ foreach (NodePort input in node.Inputs) {
Rect rect;
if (portConnectionPoints.TryGetValue(input, out rect)) {
rect.position += offset;
@@ -167,8 +167,8 @@ namespace XNodeEditor {
hoveredPort.VerifyConnections();
autoConnectOutput = null;
if (hoveredPort.IsConnected) {
- XNode.Node node = hoveredPort.node;
- XNode.NodePort output = hoveredPort.Connection;
+ Node node = hoveredPort.node;
+ NodePort output = hoveredPort.Connection;
int outputConnectionIndex = output.GetConnectionIndex(hoveredPort);
draggedOutputReroutes = output.GetReroutePoints(outputConnectionIndex);
hoveredPort.Disconnect(output);
@@ -222,7 +222,7 @@ namespace XNodeEditor {
if (IsDraggingPort) {
// If connection is valid, save it
if (draggedOutputTarget != null && graphEditor.CanConnect(draggedOutput, draggedOutputTarget)) {
- XNode.Node node = draggedOutputTarget.node;
+ Node node = draggedOutputTarget.node;
if (graph.nodes.Count != 0) draggedOutput.Connect(draggedOutputTarget);
// ConnectionIndex can be -1 if the connection is removed instantly after creation
@@ -245,8 +245,8 @@ namespace XNodeEditor {
EditorUtility.SetDirty(graph);
if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets();
} else if (currentActivity == NodeActivity.DragNode) {
- IEnumerable nodes = Selection.objects.Where(x => x is XNode.Node).Select(x => x as XNode.Node);
- foreach (XNode.Node node in nodes) EditorUtility.SetDirty(node);
+ IEnumerable nodes = Selection.objects.Where(x => x is Node).Select(x => x as Node);
+ foreach (Node node in nodes) EditorUtility.SetDirty(node);
if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets();
} else if (!IsHoveringNode) {
// If click outside node, release field focus
@@ -316,12 +316,12 @@ namespace XNodeEditor {
if (e.keyCode == KeyCode.F2) RenameSelectedNode();
}
if (e.keyCode == KeyCode.A) {
- if (Selection.objects.Any(x => graph.nodes.Contains(x as XNode.Node))) {
- foreach (XNode.Node node in graph.nodes) {
+ if (Selection.objects.Any(x => graph.nodes.Contains(x as Node))) {
+ foreach (Node node in graph.nodes) {
DeselectNode(node);
}
} else {
- foreach (XNode.Node node in graph.nodes) {
+ foreach (Node node in graph.nodes) {
SelectNode(node, true);
}
}
@@ -366,8 +366,8 @@ namespace XNodeEditor {
dragOffset = new Vector2[Selection.objects.Length + selectedReroutes.Count];
// Selected nodes
for (int i = 0; i < Selection.objects.Length; i++) {
- if (Selection.objects[i] is XNode.Node) {
- XNode.Node node = Selection.objects[i] as XNode.Node;
+ if (Selection.objects[i] is Node) {
+ Node node = Selection.objects[i] as Node;
dragOffset[i] = node.position - WindowToGridPosition(current.mousePosition);
}
}
@@ -380,7 +380,7 @@ namespace XNodeEditor {
/// Puts all selected nodes in focus. If no nodes are present, resets view and zoom to to origin
public void Home() {
- var nodes = Selection.objects.Where(o => o is XNode.Node).Cast().ToList();
+ var nodes = Selection.objects.Where(o => o is Node).Cast().ToList();
if (nodes.Count > 0) {
Vector2 minPos = nodes.Select(x => x.position).Aggregate((x, y) => new Vector2(Mathf.Min(x.x, y.x), Mathf.Min(x.y, y.y)));
Vector2 maxPos = nodes.Select(x => x.position + (nodeSizes.ContainsKey(x) ? nodeSizes[x] : Vector2.zero)).Aggregate((x, y) => new Vector2(Mathf.Max(x.x, y.x), Mathf.Max(x.y, y.y)));
@@ -400,8 +400,8 @@ namespace XNodeEditor {
}
selectedReroutes.Clear();
foreach (UnityEngine.Object item in Selection.objects) {
- if (item is XNode.Node) {
- XNode.Node node = item as XNode.Node;
+ if (item is Node) {
+ Node node = item as Node;
graphEditor.RemoveNode(node);
}
}
@@ -409,8 +409,8 @@ namespace XNodeEditor {
/// Initiate a rename on the currently selected node
public void RenameSelectedNode() {
- if (Selection.objects.Length == 1 && Selection.activeObject is XNode.Node) {
- XNode.Node node = Selection.activeObject as XNode.Node;
+ if (Selection.objects.Length == 1 && Selection.activeObject is Node) {
+ Node node = Selection.activeObject as Node;
Vector2 size;
if (nodeSizes.TryGetValue(node, out size)) {
RenamePopup.Show(Selection.activeObject, size.x);
@@ -421,7 +421,7 @@ namespace XNodeEditor {
}
/// Draw this node on top of other nodes by placing it last in the graph.nodes list
- public void MoveNodeToTop(XNode.Node node) {
+ public void MoveNodeToTop(Node node) {
int index;
while ((index = graph.nodes.IndexOf(node)) != graph.nodes.Count - 1) {
graph.nodes[index] = graph.nodes[index + 1];
@@ -432,7 +432,7 @@ namespace XNodeEditor {
/// Duplicate selected nodes and select the duplicates
public void DuplicateSelectedNodes() {
// Get selected nodes which are part of this graph
- XNode.Node[] selectedNodes = Selection.objects.Select(x => x as XNode.Node).Where(x => x != null && x.graph == graph).ToArray();
+ Node[] selectedNodes = Selection.objects.Select(x => x as Node).Where(x => x != null && x.graph == graph).ToArray();
if (selectedNodes == null || selectedNodes.Length == 0) return;
// Get top left node position
Vector2 topLeftNode = selectedNodes.Select(x => x.position).Aggregate((x, y) => new Vector2(Mathf.Min(x.x, y.x), Mathf.Min(x.y, y.y)));
@@ -440,14 +440,14 @@ namespace XNodeEditor {
}
public void CopySelectedNodes() {
- copyBuffer = Selection.objects.Select(x => x as XNode.Node).Where(x => x != null && x.graph == graph).ToArray();
+ copyBuffer = Selection.objects.Select(x => x as Node).Where(x => x != null && x.graph == graph).ToArray();
}
public void PasteNodes(Vector2 pos) {
InsertDuplicateNodes(copyBuffer, pos);
}
- private void InsertDuplicateNodes(XNode.Node[] nodes, Vector2 topLeft) {
+ private void InsertDuplicateNodes(Node[] nodes, Vector2 topLeft) {
if (nodes == null || nodes.Length == 0) return;
// Get top-left node
@@ -455,20 +455,20 @@ namespace XNodeEditor {
Vector2 offset = topLeft - topLeftNode;
UnityEngine.Object[] newNodes = new UnityEngine.Object[nodes.Length];
- Dictionary substitutes = new Dictionary();
+ Dictionary substitutes = new Dictionary();
for (int i = 0; i < nodes.Length; i++) {
- XNode.Node srcNode = nodes[i];
+ Node srcNode = nodes[i];
if (srcNode == null) continue;
// Check if user is allowed to add more of given node type
- XNode.Node.DisallowMultipleNodesAttribute disallowAttrib;
+ Node.DisallowMultipleNodesAttribute disallowAttrib;
Type nodeType = srcNode.GetType();
if (NodeEditorUtilities.GetAttrib(nodeType, out disallowAttrib)) {
int typeCount = graph.nodes.Count(x => x.GetType() == nodeType);
if (typeCount >= disallowAttrib.max) continue;
}
- XNode.Node newNode = graphEditor.CopyNode(srcNode);
+ Node newNode = graphEditor.CopyNode(srcNode);
substitutes.Add(srcNode, newNode);
newNode.position = srcNode.position + offset;
newNodes[i] = newNode;
@@ -476,14 +476,14 @@ namespace XNodeEditor {
// Walk through the selected nodes again, recreate connections, using the new nodes
for (int i = 0; i < nodes.Length; i++) {
- XNode.Node srcNode = nodes[i];
+ Node srcNode = nodes[i];
if (srcNode == null) continue;
- foreach (XNode.NodePort port in srcNode.Ports) {
+ foreach (NodePort port in srcNode.Ports) {
for (int c = 0; c < port.ConnectionCount; c++) {
- XNode.NodePort inputPort = port.direction == XNode.NodePort.IO.Input ? port : port.GetConnection(c);
- XNode.NodePort outputPort = port.direction == XNode.NodePort.IO.Output ? port : port.GetConnection(c);
+ NodePort inputPort = port.direction == NodePort.IO.Input ? port : port.GetConnection(c);
+ NodePort outputPort = port.direction == NodePort.IO.Output ? port : port.GetConnection(c);
- XNode.Node newNodeIn, newNodeOut;
+ Node newNodeIn, newNodeOut;
if (substitutes.TryGetValue(inputPort.node, out newNodeIn) && substitutes.TryGetValue(outputPort.node, out newNodeOut)) {
newNodeIn.UpdatePorts();
newNodeOut.UpdatePorts();
@@ -537,7 +537,7 @@ namespace XNodeEditor {
}
}
- bool IsHoveringTitle(XNode.Node node) {
+ bool IsHoveringTitle(Node node) {
Vector2 mousePos = Event.current.mousePosition;
//Get node position
Vector2 nodePos = GridToWindowPosition(node.position);
@@ -550,11 +550,11 @@ namespace XNodeEditor {
}
/// Attempt to connect dragged output to target node
- public void AutoConnect(XNode.Node node) {
+ public void AutoConnect(Node node) {
if (autoConnectOutput == null) return;
// Find compatible input port
- XNode.NodePort inputPort = node.Ports.FirstOrDefault(x => x.IsInput && graphEditor.CanConnect(autoConnectOutput, x));
+ NodePort inputPort = node.Ports.FirstOrDefault(x => x.IsInput && graphEditor.CanConnect(autoConnectOutput, x));
if (inputPort != null) autoConnectOutput.Connect(inputPort);
// Save changes
diff --git a/Scripts/Editor/NodeEditorAssetModProcessor.cs b/Scripts/Editor/NodeEditorAssetModProcessor.cs
index f4b14a2..82472eb 100644
--- a/Scripts/Editor/NodeEditorAssetModProcessor.cs
+++ b/Scripts/Editor/NodeEditorAssetModProcessor.cs
@@ -22,7 +22,7 @@ namespace XNodeEditor {
// Check script type. Return if deleting a non-node script
UnityEditor.MonoScript script = obj as UnityEditor.MonoScript;
System.Type scriptType = script.GetClass ();
- if (scriptType == null || (scriptType != typeof (XNode.Node) && !scriptType.IsSubclassOf (typeof (XNode.Node)))) return AssetDeleteResult.DidNotDelete;
+ if (scriptType == null || (scriptType != typeof (Node) && !scriptType.IsSubclassOf (typeof (Node)))) return AssetDeleteResult.DidNotDelete;
// Find all ScriptableObjects using this script
string[] guids = AssetDatabase.FindAssets ("t:" + scriptType);
@@ -30,7 +30,7 @@ namespace XNodeEditor {
string assetpath = AssetDatabase.GUIDToAssetPath (guids[i]);
Object[] objs = AssetDatabase.LoadAllAssetRepresentationsAtPath (assetpath);
for (int k = 0; k < objs.Length; k++) {
- XNode.Node node = objs[k] as XNode.Node;
+ Node node = objs[k] as Node;
if (node.GetType () == scriptType) {
if (node != null && node.graph != null) {
// Delete the node and notify the user
@@ -48,17 +48,17 @@ namespace XNodeEditor {
[InitializeOnLoadMethod]
private static void OnReloadEditor () {
// Find all NodeGraph assets
- string[] guids = AssetDatabase.FindAssets ("t:" + typeof (XNode.NodeGraph));
+ string[] guids = AssetDatabase.FindAssets ("t:" + typeof (NodeGraph));
for (int i = 0; i < guids.Length; i++) {
string assetpath = AssetDatabase.GUIDToAssetPath (guids[i]);
- XNode.NodeGraph graph = AssetDatabase.LoadAssetAtPath (assetpath, typeof (XNode.NodeGraph)) as XNode.NodeGraph;
+ NodeGraph graph = AssetDatabase.LoadAssetAtPath (assetpath, typeof (NodeGraph)) as NodeGraph;
graph.nodes.RemoveAll(x => x == null); //Remove null items
Object[] objs = AssetDatabase.LoadAllAssetRepresentationsAtPath (assetpath);
// Ensure that all sub node assets are present in the graph node list
for (int u = 0; u < objs.Length; u++) {
// Ignore null sub assets
if (objs[u] == null) continue;
- if (!graph.nodes.Contains (objs[u] as XNode.Node)) graph.nodes.Add(objs[u] as XNode.Node);
+ if (!graph.nodes.Contains (objs[u] as Node)) graph.nodes.Add(objs[u] as Node);
}
}
}
diff --git a/Scripts/Editor/NodeEditorGUI.cs b/Scripts/Editor/NodeEditorGUI.cs
index 35b2e2a..c37a624 100755
--- a/Scripts/Editor/NodeEditorGUI.cs
+++ b/Scripts/Editor/NodeEditorGUI.cs
@@ -13,7 +13,7 @@ namespace XNodeEditor {
public partial class NodeEditorWindow {
public NodeGraphEditor graphEditor;
private List selectionCache;
- private List culledNodes;
+ private List culledNodes;
/// 19 if docked, 22 if not
private int topPadding { get { return isDocked() ? 19 : 22; } }
/// Executed after all other window GUI. Useful if Zoom is ruining your day. Automatically resets after being run.
@@ -113,7 +113,7 @@ namespace XNodeEditor {
}
/// Show right-click context menu for hovered port
- void ShowPortContextMenu(XNode.NodePort hoveredPort) {
+ void ShowPortContextMenu(NodePort hoveredPort) {
GenericMenu contextMenu = new GenericMenu();
foreach (var port in hoveredPort.GetConnections()) {
var name = port.node.name;
@@ -125,10 +125,10 @@ namespace XNodeEditor {
if (NodeEditorPreferences.GetSettings().createFilter) {
contextMenu.AddSeparator("");
- if (hoveredPort.direction == XNode.NodePort.IO.Input)
- graphEditor.AddContextMenuItems(contextMenu, hoveredPort.ValueType, XNode.NodePort.IO.Output);
+ if (hoveredPort.direction == NodePort.IO.Input)
+ graphEditor.AddContextMenuItems(contextMenu, hoveredPort.ValueType, NodePort.IO.Output);
else
- graphEditor.AddContextMenuItems(contextMenu, hoveredPort.ValueType, XNode.NodePort.IO.Input);
+ graphEditor.AddContextMenuItems(contextMenu, hoveredPort.ValueType, NodePort.IO.Input);
}
contextMenu.DropDown(new Rect(Event.current.mousePosition, Vector2.zero));
if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets();
@@ -335,12 +335,12 @@ namespace XNodeEditor {
List gridPoints = new List(2);
Color col = GUI.color;
- foreach (XNode.Node node in graph.nodes) {
+ foreach (Node node in graph.nodes) {
//If a null node is found, return. This can happen if the nodes associated script is deleted. It is currently not possible in Unity to delete a null asset.
if (node == null) continue;
// Draw full connections and output > reroute
- foreach (XNode.NodePort output in node.Outputs) {
+ foreach (NodePort output in node.Outputs) {
//Needs cleanup. Null checks are ugly
Rect fromRect;
if (!_portConnectionPoints.TryGetValue(output, out fromRect)) continue;
@@ -349,7 +349,7 @@ namespace XNodeEditor {
GUIStyle portStyle = graphEditor.GetPortStyle(output);
for (int k = 0; k < output.ConnectionCount; k++) {
- XNode.NodePort input = output.GetConnection(k);
+ NodePort input = output.GetConnection(k);
Gradient noodleGradient = graphEditor.GetNoodleGradient(output, input);
float noodleThickness = graphEditor.GetNoodleThickness(output, input);
@@ -404,7 +404,7 @@ namespace XNodeEditor {
}
System.Reflection.MethodInfo onValidate = null;
- if (Selection.activeObject != null && Selection.activeObject is XNode.Node) {
+ if (Selection.activeObject != null && Selection.activeObject is Node) {
onValidate = Selection.activeObject.GetType().GetMethod("OnValidate");
if (onValidate != null) EditorGUI.BeginChangeCheck();
}
@@ -430,14 +430,14 @@ namespace XNodeEditor {
//Save guiColor so we can revert it
Color guiColor = GUI.color;
- List removeEntries = new List();
+ List removeEntries = new List();
- if (e.type == EventType.Layout) culledNodes = new List();
+ if (e.type == EventType.Layout) culledNodes = new List();
for (int n = 0; n < graph.nodes.Count; n++) {
// Skip null nodes. The user could be in the process of renaming scripts, so removing them at this point is not advisable.
if (graph.nodes[n] == null) continue;
if (n >= graph.nodes.Count) return;
- XNode.Node node = graph.nodes[n];
+ Node node = graph.nodes[n];
// Culling
if (e.type == EventType.Layout) {
@@ -529,14 +529,14 @@ namespace XNodeEditor {
//Check if we are hovering any of this nodes ports
//Check input ports
- foreach (XNode.NodePort input in node.Inputs) {
+ foreach (NodePort input in node.Inputs) {
//Check if port rect is available
if (!portConnectionPoints.ContainsKey(input)) continue;
Rect r = GridToWindowRectNoClipped(portConnectionPoints[input]);
if (r.Contains(mousePos)) hoveredPort = input;
}
//Check all output ports
- foreach (XNode.NodePort output in node.Outputs) {
+ foreach (NodePort output in node.Outputs) {
//Check if port rect is available
if (!portConnectionPoints.ContainsKey(output)) continue;
Rect r = GridToWindowRectNoClipped(portConnectionPoints[output]);
@@ -556,7 +556,7 @@ namespace XNodeEditor {
if (onValidate != null && EditorGUI.EndChangeCheck()) onValidate.Invoke(Selection.activeObject, null);
}
- private bool ShouldBeCulled(XNode.Node node) {
+ private bool ShouldBeCulled(Node node) {
Vector2 nodePos = GridToWindowPositionNoClipped(node.position);
if (nodePos.x / _zoom > position.width) return true; // Right
diff --git a/Scripts/Editor/NodeEditorGUILayout.cs b/Scripts/Editor/NodeEditorGUILayout.cs
index a0e3358..8bb8155 100644
--- a/Scripts/Editor/NodeEditorGUILayout.cs
+++ b/Scripts/Editor/NodeEditorGUILayout.cs
@@ -22,18 +22,18 @@ namespace XNodeEditor {
/// Make a field for a serialized property. Automatically displays relevant node port.
public static void PropertyField(SerializedProperty property, GUIContent label, bool includeChildren = true, params GUILayoutOption[] options) {
if (property == null) throw new NullReferenceException();
- XNode.Node node = property.serializedObject.targetObject as XNode.Node;
- XNode.NodePort port = node.GetPort(property.name);
+ Node node = property.serializedObject.targetObject as Node;
+ NodePort port = node.GetPort(property.name);
PropertyField(property, label, port, includeChildren);
}
/// Make a field for a serialized property. Manual node port override.
- public static void PropertyField(SerializedProperty property, XNode.NodePort port, bool includeChildren = true, params GUILayoutOption[] options) {
+ public static void PropertyField(SerializedProperty property, NodePort port, bool includeChildren = true, params GUILayoutOption[] options) {
PropertyField(property, null, port, includeChildren, options);
}
/// Make a field for a serialized property. Manual node port override.
- public static void PropertyField(SerializedProperty property, GUIContent label, XNode.NodePort port, bool includeChildren = true, params GUILayoutOption[] options) {
+ public static void PropertyField(SerializedProperty property, GUIContent label, NodePort port, bool includeChildren = true, params GUILayoutOption[] options) {
if (property == null) throw new NullReferenceException();
// If property is not a port, display a regular property field
@@ -44,10 +44,10 @@ namespace XNodeEditor {
List propertyAttributes = NodeEditorUtilities.GetCachedPropertyAttribs(port.node.GetType(), property.name);
// If property is an input, display a regular property field and put a port handle on the left side
- if (port.direction == XNode.NodePort.IO.Input) {
+ if (port.direction == NodePort.IO.Input) {
// Get data from [Input] attribute
- XNode.Node.ShowBackingValue showBacking = XNode.Node.ShowBackingValue.Unconnected;
- XNode.Node.InputAttribute inputAttribute;
+ Node.ShowBackingValue showBacking = Node.ShowBackingValue.Unconnected;
+ Node.InputAttribute inputAttribute;
bool dynamicPortList = false;
if (NodeEditorUtilities.GetCachedAttrib(port.node.GetType(), property.name, out inputAttribute)) {
dynamicPortList = inputAttribute.dynamicPortList;
@@ -55,8 +55,8 @@ namespace XNodeEditor {
}
bool usePropertyAttributes = dynamicPortList ||
- showBacking == XNode.Node.ShowBackingValue.Never ||
- (showBacking == XNode.Node.ShowBackingValue.Unconnected && port.IsConnected);
+ showBacking == Node.ShowBackingValue.Never ||
+ (showBacking == Node.ShowBackingValue.Unconnected && port.IsConnected);
float spacePadding = 0;
string tooltip = null;
@@ -79,22 +79,22 @@ namespace XNodeEditor {
if (dynamicPortList) {
Type type = GetType(property);
- XNode.Node.ConnectionType connectionType = inputAttribute != null ? inputAttribute.connectionType : XNode.Node.ConnectionType.Multiple;
+ Node.ConnectionType connectionType = inputAttribute != null ? inputAttribute.connectionType : Node.ConnectionType.Multiple;
DynamicPortList(property.name, type, property.serializedObject, port.direction, connectionType);
return;
}
switch (showBacking) {
- case XNode.Node.ShowBackingValue.Unconnected:
+ case Node.ShowBackingValue.Unconnected:
// Display a label if port is connected
if (port.IsConnected) EditorGUILayout.LabelField(label != null ? label : new GUIContent(property.displayName, tooltip));
// Display an editable property field if port is not connected
else EditorGUILayout.PropertyField(property, label, includeChildren, GUILayout.MinWidth(30));
break;
- case XNode.Node.ShowBackingValue.Never:
+ case Node.ShowBackingValue.Never:
// Display a label
EditorGUILayout.LabelField(label != null ? label : new GUIContent(property.displayName, tooltip));
break;
- case XNode.Node.ShowBackingValue.Always:
+ case Node.ShowBackingValue.Always:
// Display an editable property field
EditorGUILayout.PropertyField(property, label, includeChildren, GUILayout.MinWidth(30));
break;
@@ -104,10 +104,10 @@ namespace XNodeEditor {
float paddingLeft = NodeEditorWindow.current.graphEditor.GetPortStyle(port).padding.left;
rect.position = rect.position - new Vector2(16 + paddingLeft, -spacePadding);
// If property is an output, display a text label and put a port handle on the right side
- } else if (port.direction == XNode.NodePort.IO.Output) {
+ } else if (port.direction == NodePort.IO.Output) {
// Get data from [Output] attribute
- XNode.Node.ShowBackingValue showBacking = XNode.Node.ShowBackingValue.Unconnected;
- XNode.Node.OutputAttribute outputAttribute;
+ Node.ShowBackingValue showBacking = Node.ShowBackingValue.Unconnected;
+ Node.OutputAttribute outputAttribute;
bool dynamicPortList = false;
if (NodeEditorUtilities.GetCachedAttrib(port.node.GetType(), property.name, out outputAttribute)) {
dynamicPortList = outputAttribute.dynamicPortList;
@@ -115,8 +115,8 @@ namespace XNodeEditor {
}
bool usePropertyAttributes = dynamicPortList ||
- showBacking == XNode.Node.ShowBackingValue.Never ||
- (showBacking == XNode.Node.ShowBackingValue.Unconnected && port.IsConnected);
+ showBacking == Node.ShowBackingValue.Never ||
+ (showBacking == Node.ShowBackingValue.Unconnected && port.IsConnected);
float spacePadding = 0;
string tooltip = null;
@@ -139,22 +139,22 @@ namespace XNodeEditor {
if (dynamicPortList) {
Type type = GetType(property);
- XNode.Node.ConnectionType connectionType = outputAttribute != null ? outputAttribute.connectionType : XNode.Node.ConnectionType.Multiple;
+ Node.ConnectionType connectionType = outputAttribute != null ? outputAttribute.connectionType : Node.ConnectionType.Multiple;
DynamicPortList(property.name, type, property.serializedObject, port.direction, connectionType);
return;
}
switch (showBacking) {
- case XNode.Node.ShowBackingValue.Unconnected:
+ case Node.ShowBackingValue.Unconnected:
// Display a label if port is connected
if (port.IsConnected) EditorGUILayout.LabelField(label != null ? label : new GUIContent(property.displayName, tooltip), NodeEditorResources.OutputPort, GUILayout.MinWidth(30));
// Display an editable property field if port is not connected
else EditorGUILayout.PropertyField(property, label, includeChildren, GUILayout.MinWidth(30));
break;
- case XNode.Node.ShowBackingValue.Never:
+ case Node.ShowBackingValue.Never:
// Display a label
EditorGUILayout.LabelField(label != null ? label : new GUIContent(property.displayName, tooltip), NodeEditorResources.OutputPort, GUILayout.MinWidth(30));
break;
- case XNode.Node.ShowBackingValue.Always:
+ case Node.ShowBackingValue.Always:
// Display an editable property field
EditorGUILayout.PropertyField(property, label, includeChildren, GUILayout.MinWidth(30));
break;
@@ -185,19 +185,19 @@ namespace XNodeEditor {
}
/// Make a simple port field.
- public static void PortField(XNode.NodePort port, params GUILayoutOption[] options) {
+ public static void PortField(NodePort port, params GUILayoutOption[] options) {
PortField(null, port, options);
}
/// Make a simple port field.
- public static void PortField(GUIContent label, XNode.NodePort port, params GUILayoutOption[] options) {
+ public static void PortField(GUIContent label, NodePort port, params GUILayoutOption[] options) {
if (port == null) return;
if (options == null) options = new GUILayoutOption[] { GUILayout.MinWidth(30) };
Vector2 position = Vector3.zero;
GUIContent content = label != null ? label : new GUIContent(ObjectNames.NicifyVariableName(port.fieldName));
// If property is an input, display a regular property field and put a port handle on the left side
- if (port.direction == XNode.NodePort.IO.Input) {
+ if (port.direction == NodePort.IO.Input) {
// Display a label
EditorGUILayout.LabelField(content, options);
@@ -206,7 +206,7 @@ namespace XNodeEditor {
position = rect.position - new Vector2(16 + paddingLeft, 0);
}
// If property is an output, display a text label and put a port handle on the right side
- else if (port.direction == XNode.NodePort.IO.Output) {
+ else if (port.direction == NodePort.IO.Output) {
// Display a label
EditorGUILayout.LabelField(content, NodeEditorResources.OutputPort, options);
@@ -218,7 +218,7 @@ namespace XNodeEditor {
}
/// Make a simple port field.
- public static void PortField(Vector2 position, XNode.NodePort port) {
+ public static void PortField(Vector2 position, NodePort port) {
if (port == null) return;
Rect rect = new Rect(position, new Vector2(16, 16));
@@ -235,17 +235,17 @@ namespace XNodeEditor {
}
/// Add a port field to previous layout element.
- public static void AddPortField(XNode.NodePort port) {
+ public static void AddPortField(NodePort port) {
if (port == null) return;
Rect rect = new Rect();
// If property is an input, display a regular property field and put a port handle on the left side
- if (port.direction == XNode.NodePort.IO.Input) {
+ if (port.direction == NodePort.IO.Input) {
rect = GUILayoutUtility.GetLastRect();
float paddingLeft = NodeEditorWindow.current.graphEditor.GetPortStyle(port).padding.left;
rect.position = rect.position - new Vector2(16 + paddingLeft, 0);
// If property is an output, display a text label and put a port handle on the right side
- } else if (port.direction == XNode.NodePort.IO.Output) {
+ } else if (port.direction == NodePort.IO.Output) {
rect = GUILayoutUtility.GetLastRect();
rect.width += NodeEditorWindow.current.graphEditor.GetPortStyle(port).padding.right;
rect.position = rect.position + new Vector2(rect.width, 0);
@@ -265,7 +265,7 @@ namespace XNodeEditor {
}
/// Draws an input and an output port on the same line
- public static void PortPair(XNode.NodePort input, XNode.NodePort output) {
+ public static void PortPair(NodePort input, NodePort output) {
GUILayout.BeginHorizontal();
NodeEditorGUILayout.PortField(input, GUILayout.MinWidth(0));
NodeEditorGUILayout.PortField(output, GUILayout.MinWidth(0));
@@ -292,18 +292,18 @@ namespace XNodeEditor {
#region Obsolete
[Obsolete("Use IsDynamicPortListPort instead")]
- public static bool IsInstancePortListPort(XNode.NodePort port) {
+ public static bool IsInstancePortListPort(NodePort port) {
return IsDynamicPortListPort(port);
}
[Obsolete("Use DynamicPortList instead")]
- public static void InstancePortList(string fieldName, Type type, SerializedObject serializedObject, XNode.NodePort.IO io, XNode.Node.ConnectionType connectionType = XNode.Node.ConnectionType.Multiple, XNode.Node.TypeConstraint typeConstraint = XNode.Node.TypeConstraint.None, Action onCreation = null) {
+ public static void InstancePortList(string fieldName, Type type, SerializedObject serializedObject, NodePort.IO io, Node.ConnectionType connectionType = Node.ConnectionType.Multiple, Node.TypeConstraint typeConstraint = Node.TypeConstraint.None, Action onCreation = null) {
DynamicPortList(fieldName, type, serializedObject, io, connectionType, typeConstraint, onCreation);
}
#endregion
/// Is this port part of a DynamicPortList?
- public static bool IsDynamicPortListPort(XNode.NodePort port) {
+ public static bool IsDynamicPortListPort(NodePort port) {
string[] parts = port.fieldName.Split(' ');
if (parts.Length != 2) return false;
Dictionary cache;
@@ -320,8 +320,8 @@ namespace XNodeEditor {
/// The serializedObject of the node
/// Connection type of added dynamic ports
/// Called on the list on creation. Use this if you want to customize the created ReorderableList
- public static void DynamicPortList(string fieldName, Type type, SerializedObject serializedObject, XNode.NodePort.IO io, XNode.Node.ConnectionType connectionType = XNode.Node.ConnectionType.Multiple, XNode.Node.TypeConstraint typeConstraint = XNode.Node.TypeConstraint.None, Action onCreation = null) {
- XNode.Node node = serializedObject.targetObject as XNode.Node;
+ public static void DynamicPortList(string fieldName, Type type, SerializedObject serializedObject, NodePort.IO io, Node.ConnectionType connectionType = Node.ConnectionType.Multiple, Node.TypeConstraint typeConstraint = Node.TypeConstraint.None, Action onCreation = null) {
+ Node node = serializedObject.targetObject as Node;
var indexedPorts = node.DynamicPorts.Select(x => {
string[] split = x.fieldName.Split(' ');
@@ -331,9 +331,9 @@ namespace XNodeEditor {
return new { index = i, port = x };
}
}
- return new { index = -1, port = (XNode.NodePort)null };
+ return new { index = -1, port = (NodePort)null };
}).Where(x => x.port != null);
- List dynamicPorts = indexedPorts.OrderBy(x => x.index).Select(x => x.port).ToList();
+ List dynamicPorts = indexedPorts.OrderBy(x => x.index).Select(x => x.port).ToList();
node.UpdatePorts();
@@ -354,15 +354,15 @@ namespace XNodeEditor {
}
- private static ReorderableList CreateReorderableList(string fieldName, List dynamicPorts, SerializedProperty arrayData, Type type, SerializedObject serializedObject, XNode.NodePort.IO io, XNode.Node.ConnectionType connectionType, XNode.Node.TypeConstraint typeConstraint, Action onCreation) {
+ private static ReorderableList CreateReorderableList(string fieldName, List dynamicPorts, SerializedProperty arrayData, Type type, SerializedObject serializedObject, NodePort.IO io, Node.ConnectionType connectionType, Node.TypeConstraint typeConstraint, Action onCreation) {
bool hasArrayData = arrayData != null && arrayData.isArray;
- XNode.Node node = serializedObject.targetObject as XNode.Node;
+ Node node = serializedObject.targetObject as Node;
ReorderableList list = new ReorderableList(dynamicPorts, null, true, true, true, true);
string label = arrayData != null ? arrayData.displayName : ObjectNames.NicifyVariableName(fieldName);
list.drawElementCallback =
(Rect rect, int index, bool isActive, bool isFocused) => {
- XNode.NodePort port = node.GetPort(fieldName + " " + index);
+ NodePort port = node.GetPort(fieldName + " " + index);
if (hasArrayData && arrayData.propertyType != SerializedPropertyType.String) {
if (arrayData.arraySize <= index) {
EditorGUI.LabelField(rect, "Array[" + index + "] data out of range");
@@ -402,8 +402,8 @@ namespace XNodeEditor {
// Move up
if (rl.index > reorderableListIndex) {
for (int i = reorderableListIndex; i < rl.index; ++i) {
- XNode.NodePort port = node.GetPort(fieldName + " " + i);
- XNode.NodePort nextPort = node.GetPort(fieldName + " " + (i + 1));
+ NodePort port = node.GetPort(fieldName + " " + i);
+ NodePort nextPort = node.GetPort(fieldName + " " + (i + 1));
port.SwapConnections(nextPort);
// Swap cached positions to mitigate twitching
@@ -416,8 +416,8 @@ namespace XNodeEditor {
// Move down
else {
for (int i = reorderableListIndex; i > rl.index; --i) {
- XNode.NodePort port = node.GetPort(fieldName + " " + i);
- XNode.NodePort nextPort = node.GetPort(fieldName + " " + (i - 1));
+ NodePort port = node.GetPort(fieldName + " " + i);
+ NodePort nextPort = node.GetPort(fieldName + " " + (i - 1));
port.SwapConnections(nextPort);
// Swap cached positions to mitigate twitching
@@ -449,7 +449,7 @@ namespace XNodeEditor {
int i = 0;
while (node.HasPort(newName)) newName = fieldName + " " + (++i);
- if (io == XNode.NodePort.IO.Output) node.AddDynamicOutput(type, connectionType, XNode.Node.TypeConstraint.None, newName);
+ if (io == NodePort.IO.Output) node.AddDynamicOutput(type, connectionType, Node.TypeConstraint.None, newName);
else node.AddDynamicInput(type, connectionType, typeConstraint, newName);
serializedObject.Update();
EditorUtility.SetDirty(node);
@@ -469,7 +469,7 @@ namespace XNodeEditor {
return new { index = i, port = x };
}
}
- return new { index = -1, port = (XNode.NodePort)null };
+ return new { index = -1, port = (NodePort)null };
}).Where(x => x.port != null);
dynamicPorts = indexedPorts.OrderBy(x => x.index).Select(x => x.port).ToList();
@@ -486,7 +486,7 @@ namespace XNodeEditor {
// Move following connections one step up to replace the missing connection
for (int k = index + 1; k < dynamicPorts.Count(); k++) {
for (int j = 0; j < dynamicPorts[k].ConnectionCount; j++) {
- XNode.NodePort other = dynamicPorts[k].GetConnection(j);
+ NodePort other = dynamicPorts[k].GetConnection(j);
dynamicPorts[k].Disconnect(other);
dynamicPorts[k - 1].Connect(other);
}
@@ -523,7 +523,7 @@ namespace XNodeEditor {
string newName = arrayData.name + " 0";
int i = 0;
while (node.HasPort(newName)) newName = arrayData.name + " " + (++i);
- if (io == XNode.NodePort.IO.Output) node.AddDynamicOutput(type, connectionType, typeConstraint, newName);
+ if (io == NodePort.IO.Output) node.AddDynamicOutput(type, connectionType, typeConstraint, newName);
else node.AddDynamicInput(type, connectionType, typeConstraint, newName);
EditorUtility.SetDirty(node);
dynamicPortCount++;
diff --git a/Scripts/Editor/NodeEditorReflection.cs b/Scripts/Editor/NodeEditorReflection.cs
index d401139..6f9b6c6 100644
--- a/Scripts/Editor/NodeEditorReflection.cs
+++ b/Scripts/Editor/NodeEditorReflection.cs
@@ -28,13 +28,13 @@ namespace XNodeEditor {
public static Type[] GetNodeTypes() {
//Get all classes deriving from Node via reflection
- return GetDerivedTypes(typeof(XNode.Node));
+ return GetDerivedTypes(typeof(Node));
}
/// Custom node tint colors defined with [NodeColor(r, g, b)]
public static bool TryGetAttributeTint(this Type nodeType, out Color tint) {
if (nodeTint == null) {
- CacheAttributes(ref nodeTint, x => x.color);
+ CacheAttributes(ref nodeTint, x => x.color);
}
return nodeTint.TryGetValue(nodeType, out tint);
}
@@ -42,7 +42,7 @@ namespace XNodeEditor {
/// Get custom node widths defined with [NodeWidth(width)]
public static bool TryGetAttributeWidth(this Type nodeType, out int width) {
if (nodeWidth == null) {
- CacheAttributes(ref nodeWidth, x => x.width);
+ CacheAttributes(ref nodeWidth, x => x.width);
}
return nodeWidth.TryGetValue(nodeType, out width);
}
@@ -62,7 +62,7 @@ namespace XNodeEditor {
// If we can't find field in the first run, it's probably a private field in a base class.
FieldInfo field = type.GetField(fieldName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
// Search base classes for private fields only. Public fields are found above
- while (field == null && (type = type.BaseType) != typeof(XNode.Node)) field = type.GetField(fieldName, BindingFlags.NonPublic | BindingFlags.Instance);
+ while (field == null && (type = type.BaseType) != typeof(Node)) field = type.GetField(fieldName, BindingFlags.NonPublic | BindingFlags.Instance);
return field;
}
diff --git a/Scripts/Editor/NodeEditorUtilities.cs b/Scripts/Editor/NodeEditorUtilities.cs
index 753973b..5102936 100644
--- a/Scripts/Editor/NodeEditorUtilities.cs
+++ b/Scripts/Editor/NodeEditorUtilities.cs
@@ -134,14 +134,14 @@ namespace XNodeEditor {
/// Type to find compatiblities
///
/// True if NodeType has some port with value type compatible
- public static bool HasCompatiblePortType(Type nodeType, Type compatibleType, XNode.NodePort.IO direction = XNode.NodePort.IO.Input) {
- Type findType = typeof(XNode.Node.InputAttribute);
- if (direction == XNode.NodePort.IO.Output)
- findType = typeof(XNode.Node.OutputAttribute);
+ public static bool HasCompatiblePortType(Type nodeType, Type compatibleType, NodePort.IO direction = NodePort.IO.Input) {
+ Type findType = typeof(Node.InputAttribute);
+ if (direction == NodePort.IO.Output)
+ findType = typeof(Node.OutputAttribute);
//Get All fields from node type and we go filter only field with portAttribute.
//This way is possible to know the values of the all ports and if have some with compatible value tue
- foreach (FieldInfo f in XNode.NodeDataCache.GetNodeFields(nodeType)) {
+ foreach (FieldInfo f in NodeDataCache.GetNodeFields(nodeType)) {
var portAttribute = f.GetCustomAttributes(findType, false).FirstOrDefault();
if (portAttribute != null) {
if (IsCastableTo(f.FieldType, compatibleType)) {
@@ -159,7 +159,7 @@ namespace XNodeEditor {
/// List with all nodes type to filter
/// Compatible Type to Filter
/// Return Only Node Types with ports compatible, or an empty list
- public static List GetCompatibleNodesTypes(Type[] nodeTypes, Type compatibleType, XNode.NodePort.IO direction = XNode.NodePort.IO.Input) {
+ public static List GetCompatibleNodesTypes(Type[] nodeTypes, Type compatibleType, NodePort.IO direction = NodePort.IO.Input) {
//Result List
List filteredTypes = new List();
diff --git a/Scripts/Editor/NodeEditorWindow.cs b/Scripts/Editor/NodeEditorWindow.cs
index a7ec96b..aeee324 100644
--- a/Scripts/Editor/NodeEditorWindow.cs
+++ b/Scripts/Editor/NodeEditorWindow.cs
@@ -11,8 +11,8 @@ namespace XNodeEditor {
public static NodeEditorWindow current;
/// Stores node positions for all nodePorts.
- public Dictionary portConnectionPoints { get { return _portConnectionPoints; } }
- private Dictionary _portConnectionPoints = new Dictionary();
+ public Dictionary portConnectionPoints { get { return _portConnectionPoints; } }
+ private Dictionary _portConnectionPoints = new Dictionary();
[SerializeField] private NodePortReference[] _references = new NodePortReference[0];
[SerializeField] private Rect[] _rects = new Rect[0];
@@ -25,15 +25,15 @@ namespace XNodeEditor {
private Func _isDocked;
[System.Serializable] private class NodePortReference {
- [SerializeField] private XNode.Node _node;
+ [SerializeField] private Node _node;
[SerializeField] private string _name;
- public NodePortReference(XNode.NodePort nodePort) {
+ public NodePortReference(NodePort nodePort) {
_node = nodePort.node;
_name = nodePort.fieldName;
}
- public XNode.NodePort GetNodePort() {
+ public NodePort GetNodePort() {
if (_node == null) {
return null;
}
@@ -59,16 +59,16 @@ namespace XNodeEditor {
int length = _references.Length;
if (length == _rects.Length) {
for (int i = 0; i < length; i++) {
- XNode.NodePort nodePort = _references[i].GetNodePort();
+ NodePort nodePort = _references[i].GetNodePort();
if (nodePort != null)
_portConnectionPoints.Add(nodePort, _rects[i]);
}
}
}
- public Dictionary nodeSizes { get { return _nodeSizes; } }
- private Dictionary _nodeSizes = new Dictionary();
- public XNode.NodeGraph graph;
+ public Dictionary nodeSizes { get { return _nodeSizes; } }
+ private Dictionary _nodeSizes = new Dictionary();
+ public NodeGraph graph;
public Vector2 panOffset { get { return _panOffset; } set { _panOffset = value; Repaint(); } }
private Vector2 _panOffset;
public float zoom { get { return _zoom; } set { _zoom = Mathf.Clamp(value, NodeEditorPreferences.GetSettings().minZoom, NodeEditorPreferences.GetSettings().maxZoom); Repaint(); } }
@@ -97,7 +97,7 @@ namespace XNodeEditor {
/// Handle Selection Change events
private static void OnSelectionChanged() {
- XNode.NodeGraph nodeGraph = Selection.activeObject as XNode.NodeGraph;
+ NodeGraph nodeGraph = Selection.activeObject as NodeGraph;
if (nodeGraph && !AssetDatabase.Contains(nodeGraph)) {
if (NodeEditorPreferences.GetSettings().openOnCreate) Open(nodeGraph);
}
@@ -132,7 +132,7 @@ namespace XNodeEditor {
string path = EditorUtility.SaveFilePanelInProject("Save NodeGraph", "NewNodeGraph", "asset", "");
if (string.IsNullOrEmpty(path)) return;
else {
- XNode.NodeGraph existingGraph = AssetDatabase.LoadAssetAtPath(path);
+ NodeGraph existingGraph = AssetDatabase.LoadAssetAtPath(path);
if (existingGraph != null) AssetDatabase.DeleteAsset(path);
AssetDatabase.CreateAsset(graph, path);
EditorUtility.SetDirty(graph);
@@ -171,7 +171,7 @@ namespace XNodeEditor {
return new Vector2(xOffset, yOffset);
}
- public void SelectNode(XNode.Node node, bool add) {
+ public void SelectNode(Node node, bool add) {
if (add) {
List