1
0
mirror of https://github.com/Siccity/xNode.git synced 2026-02-25 19:21:27 +08:00

Renamed to xNode

Added XNode and XNodeEDitor namespaces
Removed unnecessary usings
This commit is contained in:
Thor Brigsted 2017-11-05 23:42:31 +01:00
parent 6fcd16abd7
commit c6a4735c71
19 changed files with 1339 additions and 1324 deletions

View File

@ -1,7 +1,7 @@
using System.Collections; using UnityEngine;
using System.Collections.Generic;
using UnityEngine;
using System; using System;
using XNode;
/// <summary> Defines an example nodegraph. </summary> /// <summary> Defines an example nodegraph. </summary>
[Serializable, CreateAssetMenu(fileName = "ExampleNodeGraph", menuName = "Node Graph/Example")] [Serializable, CreateAssetMenu(fileName = "ExampleNodeGraph", menuName = "Node Graph/Example")]
public class ExampleNodeGraph : NodeGraph { public class ExampleNodeGraph : NodeGraph {

View File

@ -1,4 +1,6 @@
namespace BasicNodes { using XNode;
namespace BasicNodes {
public class DisplayValue : Node { public class DisplayValue : Node {
[Input(ShowBackingValue.Never)] public object value; [Input(ShowBackingValue.Never)] public object value;

View File

@ -1,7 +1,5 @@
using System.Collections; using UnityEditor;
using System.Collections.Generic; using XNodeEditor;
using UnityEditor;
using UnityEngine;
namespace BasicNodes { namespace BasicNodes {
[CustomNodeEditor(typeof(DisplayValue))] [CustomNodeEditor(typeof(DisplayValue))]

View File

@ -1,4 +1,6 @@
namespace BasicNodes { using XNode;
namespace BasicNodes {
[System.Serializable] [System.Serializable]
public class MathNode : Node { public class MathNode : Node {
// Adding [Input] or [Output] is all you need to do to register a field as a valid port on your node // Adding [Input] or [Output] is all you need to do to register a field as a valid port on your node

View File

@ -1,4 +1,5 @@
using UnityEngine; using UnityEngine;
using XNode;
namespace BasicNodes { namespace BasicNodes {
public class Vector : Node { public class Vector : Node {

View File

@ -1,12 +1,13 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
using XNode;
/// <summary> Base class to derive custom Node editors from. Use this to create your own custom inspectors and editors for your nodes. </summary> namespace XNodeEditor {
public class NodeEditor { /// <summary> Base class to derive custom Node editors from. Use this to create your own custom inspectors and editors for your nodes. </summary>
public class NodeEditor {
/// <summary> Fires every whenever a node was modified through the editor </summary> /// <summary> Fires every whenever a node was modified through the editor </summary>
public static Action<Node> onUpdateNode; public static Action<Node> onUpdateNode;
public Node target; public Node target;
@ -44,10 +45,10 @@ public class NodeEditor {
public virtual int GetWidth() { public virtual int GetWidth() {
return 200; return 200;
} }
} }
[AttributeUsage(AttributeTargets.Class)] [AttributeUsage(AttributeTargets.Class)]
public class CustomNodeEditorAttribute : Attribute { public class CustomNodeEditorAttribute : Attribute {
public Type inspectedType { get { return _inspectedType; } } public Type inspectedType { get { return _inspectedType; } }
private Type _inspectedType; private Type _inspectedType;
/// <summary> Tells a NodeEditor which Node type it is an editor for </summary> /// <summary> Tells a NodeEditor which Node type it is an editor for </summary>
@ -56,4 +57,5 @@ public class CustomNodeEditorAttribute : Attribute {
public CustomNodeEditorAttribute(Type inspectedType) { public CustomNodeEditorAttribute(Type inspectedType) {
_inspectedType = inspectedType; _inspectedType = inspectedType;
} }
}
} }

View File

@ -1,10 +1,10 @@
using System; using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
using XNode;
public partial class NodeEditorWindow { namespace XNodeEditor {
public partial class NodeEditorWindow {
public static bool isPanning { get; private set; } public static bool isPanning { get; private set; }
public static Vector2 dragOffset; public static Vector2 dragOffset;
@ -142,4 +142,5 @@ public partial class NodeEditorWindow {
Rect windowRect = new Rect(nodePos, new Vector2(width / zoom, 30 / zoom)); Rect windowRect = new Rect(nodePos, new Vector2(width / zoom, 30 / zoom));
return windowRect.Contains(mousePos); return windowRect.Contains(mousePos);
} }
}
} }

View File

@ -1,9 +1,9 @@
using System.Collections; using UnityEditor;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine; using UnityEngine;
using XNode;
public class NodeEditorAssetModProcessor : UnityEditor.AssetModificationProcessor { namespace XNodeEditor {
public class NodeEditorAssetModProcessor : UnityEditor.AssetModificationProcessor {
public static AssetDeleteResult OnWillDeleteAsset(string path, RemoveAssetOptions options) { public static AssetDeleteResult OnWillDeleteAsset(string path, RemoveAssetOptions options) {
UnityEngine.Object obj = AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(path); UnityEngine.Object obj = AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(path);
@ -32,4 +32,5 @@ public class NodeEditorAssetModProcessor : UnityEditor.AssetModificationProcesso
} }
return AssetDeleteResult.DidNotDelete; return AssetDeleteResult.DidNotDelete;
} }
}
} }

View File

@ -1,11 +1,12 @@
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
using XNode;
/// <summary> Contains GUI methods </summary> namespace XNodeEditor {
public partial class NodeEditorWindow { /// <summary> Contains GUI methods </summary>
public partial class NodeEditorWindow {
private void OnGUI() { private void OnGUI() {
Event e = Event.current; Event e = Event.current;
@ -283,4 +284,5 @@ public partial class NodeEditorWindow {
} }
} else return hoveredPort.ValueType.ToString(); } else return hoveredPort.ValueType.ToString();
} }
}
} }

View File

@ -1,13 +1,11 @@
using System; using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
using XNode;
/// <summary> UNEC-specific version of <see cref="EditorGUILayout"/> </summary> namespace XNodeEditor {
public static class NodeEditorGUILayout { /// <summary> UNEC-specific version of <see cref="EditorGUILayout"/> </summary>
public static class NodeEditorGUILayout {
public static void PropertyField(SerializedProperty property, bool includeChildren = true) { public static void PropertyField(SerializedProperty property, bool includeChildren = true) {
if (property == null) throw new NullReferenceException(); if (property == null) throw new NullReferenceException();
@ -70,4 +68,5 @@ public static class NodeEditorGUILayout {
GUI.DrawTexture(rect, NodeEditorResources.dot); GUI.DrawTexture(rect, NodeEditorResources.dot);
GUI.color = col; GUI.color = col;
} }
}
} }

View File

@ -1,10 +1,10 @@
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
public static class NodeEditorPreferences { namespace XNodeEditor {
public static class NodeEditorPreferences {
/// <summary> Have we loaded the prefs yet </summary> /// <summary> Have we loaded the prefs yet </summary>
private static bool prefsLoaded = false; private static bool prefsLoaded = false;
@ -95,4 +95,5 @@ public static class NodeEditorPreferences {
generatedTypeColors.Add(type.Name, new Color(UnityEngine.Random.value, UnityEngine.Random.value, UnityEngine.Random.value)); generatedTypeColors.Add(type.Name, new Color(UnityEngine.Random.value, UnityEngine.Random.value, UnityEngine.Random.value));
return generatedTypeColors[type.Name]; return generatedTypeColors[type.Name];
} }
}
} }

View File

@ -2,10 +2,11 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using UnityEngine; using XNode;
/// <summary> Contains reflection-related info </summary> namespace XNodeEditor {
public partial class NodeEditorWindow { /// <summary> Contains reflection-related info </summary>
public partial class NodeEditorWindow {
[NonSerialized] private static Dictionary<Type, NodeEditor> customNodeEditor; [NonSerialized] private static Dictionary<Type, NodeEditor> customNodeEditor;
public static Type[] nodeTypes { get { return _nodeTypes != null ? _nodeTypes : _nodeTypes = GetNodeTypes(); } } public static Type[] nodeTypes { get { return _nodeTypes != null ? _nodeTypes : _nodeTypes = GetNodeTypes(); } }
[NonSerialized] private static Type[] _nodeTypes = null; [NonSerialized] private static Type[] _nodeTypes = null;
@ -47,4 +48,5 @@ public partial class NodeEditorWindow {
public static object ObjectFromType(Type type) { public static object ObjectFromType(Type type) {
return Activator.CreateInstance(type); return Activator.CreateInstance(type);
} }
}
} }

View File

@ -1,8 +1,7 @@
using System; using UnityEngine;
using UnityEditor;
using UnityEngine;
public static class NodeEditorResources { namespace XNodeEditor {
public static class NodeEditorResources {
//Unec textures //Unec textures
public static Texture2D gridTexture { get { return _gridTexture != null ? _gridTexture : _gridTexture = GenerateGridTexture(); } } public static Texture2D gridTexture { get { return _gridTexture != null ? _gridTexture : _gridTexture = GenerateGridTexture(); } }
private static Texture2D _gridTexture; private static Texture2D _gridTexture;
@ -91,4 +90,5 @@ public static class NodeEditorResources {
tex.Apply(); tex.Apply();
return tex; return tex;
} }
}
} }

View File

@ -1,12 +1,10 @@
using System; using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using UnityEngine;
/// <summary> A set of editor-only utilities and extensions for UnityNodeEditorBase </summary> namespace XNodeEditor {
public static class NodeEditorUtilities { /// <summary> A set of editor-only utilities and extensions for UnityNodeEditorBase </summary>
public static class NodeEditorUtilities {
public static bool GetAttrib<T>(Type classType, out T attribOut) where T : Attribute { public static bool GetAttrib<T>(Type classType, out T attribOut) where T : Attribute {
object[] attribs = classType.GetCustomAttributes(typeof(T), false); object[] attribs = classType.GetCustomAttributes(typeof(T), false);
@ -51,4 +49,5 @@ public static class NodeEditorUtilities {
); );
return methods.Count() > 0; return methods.Count() > 0;
} }
}
} }

View File

@ -1,13 +1,12 @@
using System; using System.Collections.Generic;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEditor; using UnityEditor;
using UnityEditor.Callbacks; using UnityEditor.Callbacks;
using UnityEngine; using UnityEngine;
using XNode;
[InitializeOnLoad] namespace XNodeEditor {
public partial class NodeEditorWindow : EditorWindow { [InitializeOnLoad]
public partial class NodeEditorWindow : EditorWindow {
public static NodeEditorWindow current; public static NodeEditorWindow current;
/// <summary> Stores node positions for all nodePorts. </summary> /// <summary> Stores node positions for all nodePorts. </summary>
@ -94,4 +93,5 @@ public partial class NodeEditorWindow : EditorWindow {
} }
return false; return false;
} }
}
} }

View File

@ -2,9 +2,10 @@
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
/// <summary> Base class for all nodes </summary> namespace XNode {
[Serializable] /// <summary> Base class for all nodes </summary>
public abstract class Node : ScriptableObject { [Serializable]
public abstract class Node : ScriptableObject {
public enum ShowBackingValue { public enum ShowBackingValue {
/// <summary> Never show the backing value </summary> /// <summary> Never show the backing value </summary>
Never, Never,
@ -196,4 +197,5 @@ public abstract class Node : ScriptableObject {
this.Add(keys[i], values[i]); this.Add(keys[i], values[i]);
} }
} }
}
} }

View File

@ -1,12 +1,11 @@
using System.Collections; using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using UnityEditor;
using UnityEngine; using UnityEngine;
/// <summary> Precaches reflection data in editor so we won't have to do it runtime </summary> namespace XNode {
public static class NodeDataCache { /// <summary> Precaches reflection data in editor so we won't have to do it runtime </summary>
public static class NodeDataCache {
private static PortDataCache portDataCache; private static PortDataCache portDataCache;
private static bool Initialized { get { return portDataCache != null; } } private static bool Initialized { get { return portDataCache != null; } }
@ -97,4 +96,5 @@ public static class NodeDataCache {
this.Add(keys[i], values[i]); this.Add(keys[i], values[i]);
} }
} }
}
} }

View File

@ -2,9 +2,10 @@
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
/// <summary> Base class for all node graphs </summary> namespace XNode {
[Serializable] /// <summary> Base class for all node graphs </summary>
public abstract class NodeGraph : ScriptableObject { [Serializable]
public abstract class NodeGraph : ScriptableObject {
/// <summary> All nodes in the graph. <para/> /// <summary> All nodes in the graph. <para/>
/// See: <see cref="AddNode{T}"/> </summary> /// See: <see cref="AddNode{T}"/> </summary>
@ -44,4 +45,5 @@ public abstract class NodeGraph : ScriptableObject {
public void Clear() { public void Clear() {
nodes.Clear(); nodes.Clear();
} }
}
} }

View File

@ -1,11 +1,11 @@
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using UnityEngine; using UnityEngine;
[Serializable] namespace XNode {
public class NodePort { [Serializable]
public class NodePort {
public enum IO { Input, Output } public enum IO { Input, Output }
public int ConnectionCount { get { return connections.Count; } } public int ConnectionCount { get { return connections.Count; } }
@ -243,4 +243,5 @@ public class NodePort {
return node.GetPort(fieldName); return node.GetPort(fieldName);
} }
} }
}
} }