diff --git a/Scripts/Editor/NodeEditor.cs b/Scripts/Editor/NodeEditor.cs
index cb0edb5..200d13e 100644
--- a/Scripts/Editor/NodeEditor.cs
+++ b/Scripts/Editor/NodeEditor.cs
@@ -8,13 +8,13 @@ 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.INode))]
- public class NodeEditor : XNodeEditor.Internal.NodeEditorBase {
+ public class NodeEditor : XNodeEditor.Internal.NodeEditorBase {
/// Fires every whenever a node was modified through the editor
public static Action onUpdateNode;
public static Dictionary portPositions;
- public virtual void OnHeaderGUI() {
+ public new virtual void OnHeaderGUI() {
GUILayout.Label(target.name, NodeEditorResources.styles.nodeHeader, GUILayout.Height(30));
}
@@ -93,7 +93,7 @@ namespace XNodeEditor {
[AttributeUsage(AttributeTargets.Class)]
public class CustomNodeEditorAttribute : Attribute,
- XNodeEditor.Internal.NodeEditorBase.INodeEditorAttrib {
+ XNodeEditor.Internal.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 2172b3e..f3e1d57 100644
--- a/Scripts/Editor/NodeEditorAction.cs
+++ b/Scripts/Editor/NodeEditorAction.cs
@@ -165,7 +165,7 @@ namespace XNodeEditor {
}
} else if (IsHoveringNode && IsHoveringTitle(hoveredNode)) {
// If mousedown on node header, select or deselect
- if (!Selection.Contains((UnityEngine.Object)hoveredNode)) {
+ if (!Selection.Contains((UnityEngine.Object) hoveredNode)) {
SelectNode(hoveredNode, e.control || e.shift);
if (!e.control && !e.shift) selectedReroutes.Clear();
} else if (e.control || e.shift) DeselectNode(hoveredNode);
@@ -209,24 +209,24 @@ namespace XNodeEditor {
//If connection is valid, save it
if (draggedOutputTarget != null) {
XNode.INode node = draggedOutputTarget.node;
- if (graph.nodes.Count != 0) draggedOutput.Connect(draggedOutputTarget);
+ if (graph.Nodes.Any()) draggedOutput.Connect(draggedOutputTarget);
// ConnectionIndex can be -1 if the connection is removed instantly after creation
int connectionIndex = draggedOutput.GetConnectionIndex(draggedOutputTarget);
if (connectionIndex != -1) {
draggedOutput.GetReroutePoints(connectionIndex).AddRange(draggedOutputReroutes);
if (NodeEditor.onUpdateNode != null) NodeEditor.onUpdateNode(node);
- EditorUtility.SetDirty(graph);
+ EditorUtility.SetDirty((UnityEngine.Object) graph);
}
}
//Release dragged connection
draggedOutput = null;
draggedOutputTarget = null;
- EditorUtility.SetDirty(graph);
+ EditorUtility.SetDirty((UnityEngine.Object) graph);
if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets();
} else if (currentActivity == NodeActivity.DragNode) {
IEnumerable nodes = Selection.objects.Where(x => x is XNode.INode).Select(x => x as XNode.INode);
- foreach (XNode.INode node in nodes) EditorUtility.SetDirty(node);
+ foreach (XNode.INode node in nodes) EditorUtility.SetDirty((UnityEngine.Object) node);
if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets();
} else if (!IsHoveringNode) {
// If click outside node, release field focus
@@ -245,7 +245,7 @@ namespace XNodeEditor {
// Double click to center node
if (isDoubleClick) {
Vector2 nodeDimension = nodeSizes.ContainsKey(hoveredNode) ? nodeSizes[hoveredNode] / 2 : Vector2.zero;
- panOffset = -hoverednode.Position - nodeDimension;
+ panOffset = -hoveredNode.Position - nodeDimension;
}
}
@@ -269,7 +269,7 @@ namespace XNodeEditor {
} else if (IsHoveringPort) {
ShowPortContextMenu(hoveredPort);
} else if (IsHoveringNode && IsHoveringTitle(hoveredNode)) {
- if (!Selection.Contains((UnityEngine.Object)hoveredNode)) SelectNode(hoveredNode, false);
+ if (!Selection.Contains((UnityEngine.Object) hoveredNode)) SelectNode(hoveredNode, false);
GenericMenu menu = new GenericMenu();
NodeEditor.GetEditor(hoveredNode, this).AddContextMenuItems(menu);
menu.DropDown(new Rect(Event.current.mousePosition, Vector2.zero));
diff --git a/Scripts/Editor/NodeEditorBase.cs b/Scripts/Editor/NodeEditorBase.cs
index b701f66..af371d6 100644
--- a/Scripts/Editor/NodeEditorBase.cs
+++ b/Scripts/Editor/NodeEditorBase.cs
@@ -10,7 +10,7 @@ namespace XNodeEditor.Internal {
/// Editor Type. Should be the type of the deriving script itself (eg. NodeEditor)
/// Attribute Type. The attribute used to connect with the runtime type (eg. CustomNodeEditorAttribute)
/// Runtime Type. The Object this can be an editor for (eg. Node)
- public abstract class NodeEditorBase : Editor where A : Attribute, NodeEditorBase.INodeEditorAttrib where T : NodeEditorBase where K : UnityEngine.Object {
+ public abstract class NodeEditorBase : Editor where A : Attribute, INodeEditorAttrib where T : NodeEditorBase where K : UnityEngine.Object {
/// Custom editors defined with [CustomNodeEditor]
private static Dictionary editorTypes;
private static Dictionary editors = new Dictionary();
@@ -18,17 +18,17 @@ namespace XNodeEditor.Internal {
public new K target { get { return _target == base.target ? _target : _target = (K) base.target; } set { base.target = value; } }
private K _target;
- public static T GetEditor(K target, NodeEditorWindow window) {
- if (target == null) return null;
+ public static T GetEditor(Q target, NodeEditorWindow window) where Q : class {
+ if ((target as UnityEngine.Object) == null) return default(T);
T editor;
- if (!editors.TryGetValue(target, out editor)) {
+ if (!editors.TryGetValue(target as K, out editor)) {
Type type = target.GetType();
Type editorType = GetEditorType(type);
- editor = (T) Editor.CreateEditor(target, editorType);
+ editor = (T) Editor.CreateEditor(target as UnityEngine.Object, editorType);
editor.window = window;
- editors.Add(target, editor);
+ editors.Add(target as K, editor);
}
- if (editor.target == null) editor.Initialize(new UnityEngine.Object[] { target });
+ if (editor.target == null) editor.Initialize(new UnityEngine.Object[] { target as UnityEngine.Object });
if (editor.window != window) editor.window = window;
return editor;
}
@@ -55,9 +55,9 @@ namespace XNodeEditor.Internal {
editorTypes.Add(attrib.GetInspectedType(), nodeEditors[i]);
}
}
+ }
- public interface INodeEditorAttrib {
- Type GetInspectedType();
- }
+ public interface INodeEditorAttrib {
+ Type GetInspectedType();
}
}
\ No newline at end of file
diff --git a/Scripts/Editor/NodeGraphEditor.cs b/Scripts/Editor/NodeGraphEditor.cs
index cbed33a..d0c4f71 100644
--- a/Scripts/Editor/NodeGraphEditor.cs
+++ b/Scripts/Editor/NodeGraphEditor.cs
@@ -34,7 +34,7 @@ namespace XNodeEditor {
/// Returns context node menu path. Null or empty strings for hidden nodes.
public virtual string GetNodeMenuName(Type type) {
//Check if type has the CreateNodeMenuAttribute
- XNode.INode.CreateNodeMenuAttribute attrib;
+ XNode.Node.CreateNodeMenuAttribute attrib;
if (NodeEditorUtilities.GetAttrib(type, out attrib)) // Return custom path
return attrib.menuName;
else // Return generated path
@@ -70,8 +70,8 @@ namespace XNodeEditor {
/// Create a node and save it in the graph asset
public virtual void CreateNode(Type type, Vector2 position) {
- XNode.INode node = target.AddNode(type);
- node.Position = position;
+ XNode.Node node = target.AddNode(type);
+ node.position = position;
if (string.IsNullOrEmpty(node.name)) node.name = UnityEditor.ObjectNames.NicifyVariableName(type.Name);
AssetDatabase.AddObjectToAsset(node, target);
if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets();
@@ -79,8 +79,8 @@ namespace XNodeEditor {
}
/// Creates a copy of the original node in the graph
- public XNode.INode CopyNode(XNode.INode original) {
- XNode.INode node = target.CopyNode(original);
+ public XNode.INode CopyNode(XNode.Node original) {
+ XNode.Node node = target.CopyNode( original);
node.name = original.name;
AssetDatabase.AddObjectToAsset(node, target);
if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets();
@@ -88,7 +88,7 @@ namespace XNodeEditor {
}
/// Safely remove a node and all its connections.
- public void RemoveNode(XNode.INode node) {
+ public void RemoveNode(XNode.Node node) {
UnityEngine.Object.DestroyImmediate(node, true);
target.RemoveNode(node);
if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets();
@@ -96,7 +96,7 @@ namespace XNodeEditor {
[AttributeUsage(AttributeTargets.Class)]
public class CustomNodeGraphEditorAttribute : Attribute,
- XNodeEditor.Internal.NodeEditorBase.INodeEditorAttrib {
+ XNodeEditor.Internal.INodeEditorAttrib {
private Type inspectedType;
public string editorPrefsKey;
/// Tells a NodeGraphEditor which Graph type it is an editor for