diff --git a/README.md b/README.md index 2826650..a411b17 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,10 @@ ### xNode Thinking of developing a node-based plugin? Then this is for you. You can download it as an archive and unpack to a new unity project, or connect it as git submodule. -With a minimal footprint, xNode is ideal as a base for custom state machines, dialogue systems, decision makers etc. +xNode is super userfriendly, intuitive and will help you reap the benefits of node graphs in no time. +With a minimal footprint, it is ideal as a base for custom state machines, dialogue systems, decision makers etc. -![editor](https://user-images.githubusercontent.com/6402525/31379481-a9c15950-adae-11e7-91c4-387dd020261e.png) +![editor](https://user-images.githubusercontent.com/6402525/33150712-01d60602-cfd5-11e7-83b4-eb008fd9d711.png) ### Key features * Lightweight in runtime diff --git a/Scripts/Editor/NodeEditor.cs b/Scripts/Editor/NodeEditor.cs index 838cdc6..d8c89e3 100644 --- a/Scripts/Editor/NodeEditor.cs +++ b/Scripts/Editor/NodeEditor.cs @@ -7,6 +7,7 @@ using XNode; 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(Node))] public class NodeEditor : XNodeInternal.NodeEditorBase { @@ -48,6 +49,12 @@ namespace XNodeEditor { return 200; } + public virtual Color GetTint() { + Type type = GetType(); + if (NodeEditorWindow.nodeTint.ContainsKey(type)) return NodeEditorWindow.nodeTint[type]; + else return Color.white; + } + [AttributeUsage(AttributeTargets.Class)] public class CustomNodeEditorAttribute : Attribute, INodeEditorAttrib { diff --git a/Scripts/Editor/NodeEditorGUI.cs b/Scripts/Editor/NodeEditorGUI.cs index f7625c8..9be5256 100644 --- a/Scripts/Editor/NodeEditorGUI.cs +++ b/Scripts/Editor/NodeEditorGUI.cs @@ -7,10 +7,15 @@ using XNode; namespace XNodeEditor { /// Contains GUI methods public partial class NodeEditorWindow { + NodeGraphEditor currentGraphEditor; private void OnGUI() { Event e = Event.current; Matrix4x4 m = GUI.matrix; + currentGraphEditor = NodeGraphEditor.GetEditor(graph.GetType()); + currentGraphEditor.target = graph; + currentGraphEditor.serializedObject = new SerializedObject(graph); + Controls(); DrawGrid(position, zoom, panOffset); @@ -42,12 +47,12 @@ namespace XNodeEditor { GUI.matrix = Matrix4x4.TRS(offset, Quaternion.identity, Vector3.one); } - public static void DrawGrid(Rect rect, float zoom, Vector2 panOffset) { + public void DrawGrid(Rect rect, float zoom, Vector2 panOffset) { rect.position = Vector2.zero; Vector2 center = rect.size / 2f; - Texture2D gridTex = NodeEditorPreferences.gridTexture; + Texture2D gridTex = currentGraphEditor.GetGridTexture(); Texture2D crossTex = NodeEditorPreferences.crossTexture; // Offset from origin in tile units @@ -204,7 +209,7 @@ namespace XNodeEditor { GUILayout.BeginArea(new Rect(nodePos, new Vector2(nodeEditor.GetWidth(), 4000))); GUIStyle style = NodeEditorResources.styles.nodeBody; - if (nodeTint.ContainsKey(nodeType)) GUI.color = nodeTint[nodeType]; + GUI.color = nodeEditor.GetTint(); GUILayout.BeginVertical(new GUIStyle(style)); GUI.color = guiColor; EditorGUI.BeginChangeCheck();