diff --git a/Examples/Nodes/BaseNode.cs b/Examples/Nodes/BaseNode.cs index 1338a36..203ddd8 100644 --- a/Examples/Nodes/BaseNode.cs +++ b/Examples/Nodes/BaseNode.cs @@ -1,9 +1,6 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using UnityEngine; +public class BaseNode : Node { -public class BaseNode : Node { + public string asdf; protected override void Init() { inputs = new NodePort[2]; diff --git a/Scripts/Editor/NodeEditorGUI.cs b/Scripts/Editor/NodeEditorGUI.cs index e3eb2a1..a7373db 100644 --- a/Scripts/Editor/NodeEditorGUI.cs +++ b/Scripts/Editor/NodeEditorGUI.cs @@ -7,6 +7,22 @@ using System; /// Contains GUI methods public partial class NodeEditorWindow { + private void OnGUI() { + Event e = Event.current; + Matrix4x4 m = GUI.matrix; + Controls(); + + if (e.type != EventType.MouseMove && e.type != EventType.MouseDrag) { + DrawGrid(position, zoom, panOffset); + DrawNodes(); + DrawConnections(); + DrawDraggedConnection(); + DrawToolbar(); + } + + GUI.matrix = m; + } + public static void DrawConnection(Vector2 from, Vector2 to, Color col) { Handles.DrawBezier(from, to, from, to, col, new Texture2D(2, 2), 2); } diff --git a/Scripts/Editor/NodeEditorResources.cs b/Scripts/Editor/NodeEditorResources.cs index 4535aef..1297ae0 100644 --- a/Scripts/Editor/NodeEditorResources.cs +++ b/Scripts/Editor/NodeEditorResources.cs @@ -23,6 +23,7 @@ public partial class NodeEditorWindow { GUIStyle outputInt, outputString, outputFloat, outputObject, outputTexture, outputColor; public Styles() { + inputObject = new GUIStyle((GUIStyle)"flow shader in 0"); inputString = new GUIStyle((GUIStyle)"flow shader in 1"); inputInt = new GUIStyle((GUIStyle)"flow shader in 2"); @@ -45,6 +46,7 @@ public partial class NodeEditorWindow { } public GUIStyle GetInputStyle(Type type) { + if (type == typeof(int)) return inputInt; else if (type == typeof(string)) return inputString; else if (type == typeof(Texture2D)) return inputTexture; diff --git a/Scripts/Editor/NodeEditorWindow.cs b/Scripts/Editor/NodeEditorWindow.cs index 9f29740..361c3c0 100644 --- a/Scripts/Editor/NodeEditorWindow.cs +++ b/Scripts/Editor/NodeEditorWindow.cs @@ -26,20 +26,6 @@ public partial class NodeEditorWindow : EditorWindow { w.Show(); } - private void OnGUI() { - Event e = Event.current; - Matrix4x4 m = GUI.matrix; - Controls(); - - DrawGrid(position, zoom, panOffset); - DrawNodes(); - DrawConnections(); - DrawDraggedConnection(); - if (e.type == EventType.Repaint || e.type == EventType.Layout) DrawToolbar(); - - GUI.matrix = m; - } - public void DrawConnections() { foreach(Node node in graph.nodes) { for (int i = 0; i < node.OutputCount; i++) { @@ -95,8 +81,7 @@ public partial class NodeEditorWindow : EditorWindow { GUILayout.EndHorizontal(); - GUILayout.Label("More stuff"); - EditorGUILayout.Toggle("aDF",false); + // GUI GUILayout.EndArea(); @@ -113,9 +98,6 @@ public partial class NodeEditorWindow : EditorWindow { private void DraggableWindow(int windowID) { GUI.DragWindow(); - - if (GUILayout.Button("ASDF")) Debug.Log("ASDF"); - if (GUI.Button(new Rect(20,20,200,200),"ASDF")) Debug.Log("ASDF"); } public Vector2 WindowToGridPosition(Vector2 windowPosition) { diff --git a/Scripts/Node.cs b/Scripts/Node.cs index 24f6eab..08366a1 100644 --- a/Scripts/Node.cs +++ b/Scripts/Node.cs @@ -41,11 +41,11 @@ public abstract class Node { return outputs[portId]; } - public NodePort CreateNodeInput(string name, Type type, bool enabled = true) { - return new NodePort(name, type, this, enabled, NodePort.IO.Input); + public NodePort CreateNodeInput(string name, Type type) { + return new NodePort(name, type, this, NodePort.IO.Input); } - public NodePort CreateNodeOutput(string name, Type type, bool enabled = true) { - return new NodePort(name, type, this, enabled, NodePort.IO.Output); + public NodePort CreateNodeOutput(string name, Type type) { + return new NodePort(name, type, this, NodePort.IO.Output); } public void ClearConnections() { diff --git a/Scripts/NodePort.cs b/Scripts/NodePort.cs index df2967a..b4c562d 100644 --- a/Scripts/NodePort.cs +++ b/Scripts/NodePort.cs @@ -27,12 +27,11 @@ public class NodePort { private List connections = new List(); [SerializeField] private string _name; - [SerializeField] private bool _enabled; + [SerializeField] private bool _enabled = true; [SerializeField] private IO _direction; - public NodePort(string name, Type type, Node node, bool enabled, IO direction) { + public NodePort(string name, Type type, Node node, IO direction) { _name = name; - _enabled = enabled; _type = type; this.node = node; _direction = direction; diff --git a/Textures.meta b/Textures.meta deleted file mode 100644 index 891fa0a..0000000 --- a/Textures.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 003638a12027abc46ba0fa1719d11246 -folderAsset: yes -timeCreated: 1505424851 -licenseType: Free -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Textures/Grid.png b/Textures/Grid.png deleted file mode 100644 index 1c4457e..0000000 Binary files a/Textures/Grid.png and /dev/null differ diff --git a/Textures/Grid.png.meta b/Textures/Grid.png.meta deleted file mode 100644 index 3c0be3f..0000000 --- a/Textures/Grid.png.meta +++ /dev/null @@ -1,82 +0,0 @@ -fileFormatVersion: 2 -guid: 00e76aa739b5f474fabc717677698eef -timeCreated: 1505424840 -licenseType: Free -TextureImporter: - fileIDToRecycleName: {} - serializedVersion: 4 - mipmaps: - mipMapMode: 0 - enableMipMap: 0 - sRGBTexture: 0 - linearTexture: 0 - fadeOut: 0 - borderMipMap: 0 - mipMapsPreserveCoverage: 0 - alphaTestReferenceValue: 0.5 - mipMapFadeDistanceStart: 1 - mipMapFadeDistanceEnd: 3 - bumpmap: - convertToNormalMap: 0 - externalNormalMap: 0 - heightScale: 0.25 - normalMapFilter: 0 - isReadable: 0 - grayScaleToAlpha: 0 - generateCubemap: 6 - cubemapConvolution: 0 - seamlessCubemap: 0 - textureFormat: 1 - maxTextureSize: 2048 - textureSettings: - serializedVersion: 2 - filterMode: -1 - aniso: 1 - mipBias: -1 - wrapU: 1 - wrapV: 1 - wrapW: 1 - nPOTScale: 0 - lightmap: 0 - compressionQuality: 50 - spriteMode: 1 - spriteExtrude: 1 - spriteMeshType: 1 - alignment: 0 - spritePivot: {x: 0.5, y: 0.5} - spriteBorder: {x: 0, y: 0, z: 0, w: 0} - spritePixelsToUnits: 100 - alphaUsage: 1 - alphaIsTransparency: 1 - spriteTessellationDetail: -1 - textureType: 2 - textureShape: 1 - maxTextureSizeSet: 0 - compressionQualitySet: 0 - textureFormatSet: 0 - platformSettings: - - buildTarget: DefaultTexturePlatform - maxTextureSize: 2048 - textureFormat: -1 - textureCompression: 1 - compressionQuality: 50 - crunchedCompression: 0 - allowsAlphaSplitting: 0 - overridden: 0 - - buildTarget: Standalone - maxTextureSize: 2048 - textureFormat: -1 - textureCompression: 1 - compressionQuality: 50 - crunchedCompression: 0 - allowsAlphaSplitting: 0 - overridden: 0 - spriteSheet: - serializedVersion: 2 - sprites: [] - outline: [] - physicsShape: [] - spritePackingTag: - userData: - assetBundleName: - assetBundleVariant: