From e05327fc0cbd891ef6f68437d477a4d2f529e39e Mon Sep 17 00:00:00 2001 From: Thor Brigsted Date: Wed, 25 Sep 2019 16:36:50 +0200 Subject: [PATCH] Added simple styling --- Examples/LogicToy/Editor/LogicNodeEditor.cs | 12 +++++ Examples/LogicToy/Example.asset | 57 ++++++++++++++++++--- Examples/LogicToy/Nodes/AndNode.cs | 6 +-- Examples/LogicToy/Nodes/NotNode.cs | 6 +-- Examples/LogicToy/Nodes/PulseNode.cs | 5 +- Examples/LogicToy/Nodes/ToggleNode.cs | 6 +-- 6 files changed, 75 insertions(+), 17 deletions(-) diff --git a/Examples/LogicToy/Editor/LogicNodeEditor.cs b/Examples/LogicToy/Editor/LogicNodeEditor.cs index c1d15bd..7426771 100644 --- a/Examples/LogicToy/Editor/LogicNodeEditor.cs +++ b/Examples/LogicToy/Editor/LogicNodeEditor.cs @@ -25,5 +25,17 @@ namespace XNodeEditor.Examples.LogicToy { GUI.DrawTexture(dotRect, NodeEditorResources.dot); GUI.color = Color.white; } + + public override void OnBodyGUI() { + NodePort input = target.GetPort("input"); + NodePort output = target.GetPort("output"); + + GUILayout.BeginHorizontal(); + if (input != null) NodeEditorGUILayout.PortField(GUIContent.none, input, GUILayout.MinWidth(0)); + if (output != null) NodeEditorGUILayout.PortField(GUIContent.none, output, GUILayout.MinWidth(0)); + GUILayout.EndHorizontal(); + EditorGUIUtility.labelWidth = 60; + base.OnBodyGUI(); + } } } \ No newline at end of file diff --git a/Examples/LogicToy/Example.asset b/Examples/LogicToy/Example.asset index 612cdb1..3831ce0 100644 --- a/Examples/LogicToy/Example.asset +++ b/Examples/LogicToy/Example.asset @@ -19,6 +19,7 @@ MonoBehaviour: - {fileID: 114194736576219100} - {fileID: 114558631167130670} - {fileID: 114481634605117190} + - {fileID: 114463302483022418} --- !u!114 &114046633862954194 MonoBehaviour: m_ObjectHideFlags: 0 @@ -48,7 +49,7 @@ MonoBehaviour: _connectionType: 0 _typeConstraint: 0 _dynamic: 0 - interval: 2 + interval: 1 output: 0 --- !u!114 &114194736576219100 MonoBehaviour: @@ -96,6 +97,47 @@ MonoBehaviour: _typeConstraint: 0 _dynamic: 0 input: 0 + output: 1 +--- !u!114 &114463302483022418 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c4bb0f0e96df60a4690ca03082a93b44, type: 3} + m_Name: Not + m_EditorClassIdentifier: + graph: {fileID: 11400000} + position: {x: 88, y: -248} + ports: + keys: + - input + - output + values: + - _fieldName: input + _node: {fileID: 114463302483022418} + _typeQualifiedName: System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + connections: + - fieldName: output + node: {fileID: 114880916489599218} + reroutePoints: [] + _direction: 0 + _connectionType: 0 + _typeConstraint: 0 + _dynamic: 0 + - _fieldName: output + _node: {fileID: 114463302483022418} + _typeQualifiedName: System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + connections: [] + _direction: 1 + _connectionType: 0 + _typeConstraint: 0 + _dynamic: 0 + input: 1 output: 0 --- !u!114 &114481634605117190 MonoBehaviour: @@ -167,7 +209,7 @@ MonoBehaviour: _connectionType: 0 _typeConstraint: 0 _dynamic: 0 - input: 0 + input: 1 output: 0 --- !u!114 &114880916489599218 MonoBehaviour: @@ -207,12 +249,15 @@ MonoBehaviour: - fieldName: input node: {fileID: 114945579453429622} reroutePoints: [] + - fieldName: input + node: {fileID: 114463302483022418} + reroutePoints: [] _direction: 1 _connectionType: 0 _typeConstraint: 0 _dynamic: 0 input: 0 - output: 0 + output: 1 --- !u!114 &114944478030018250 MonoBehaviour: m_ObjectHideFlags: 0 @@ -242,7 +287,7 @@ MonoBehaviour: _connectionType: 0 _typeConstraint: 0 _dynamic: 0 - interval: 1 + interval: 1.06 output: 0 --- !u!114 &114945579453429622 MonoBehaviour: @@ -289,5 +334,5 @@ MonoBehaviour: _connectionType: 0 _typeConstraint: 0 _dynamic: 0 - input: 0 - output: 0 + input: 1 + output: 1 diff --git a/Examples/LogicToy/Nodes/AndNode.cs b/Examples/LogicToy/Nodes/AndNode.cs index ba3f4cf..04fcbe6 100644 --- a/Examples/LogicToy/Nodes/AndNode.cs +++ b/Examples/LogicToy/Nodes/AndNode.cs @@ -2,10 +2,10 @@ using UnityEngine; namespace XNode.Examples.LogicToy { - [NodeWidth(140)] + [NodeWidth(140), NodeTint(100, 70, 70)] public class AndNode : LogicNode { - [Input] public bool input; - [Output] public bool output; + [Input, HideInInspector] public bool input; + [Output, HideInInspector] public bool output; public override bool led { get { return output; } } protected override void OnInputChanged() { diff --git a/Examples/LogicToy/Nodes/NotNode.cs b/Examples/LogicToy/Nodes/NotNode.cs index c7eaf85..1170757 100644 --- a/Examples/LogicToy/Nodes/NotNode.cs +++ b/Examples/LogicToy/Nodes/NotNode.cs @@ -2,10 +2,10 @@ using UnityEngine; namespace XNode.Examples.LogicToy { - [NodeWidth(140)] + [NodeWidth(140), NodeTint(100, 100, 50)] public class NotNode : LogicNode { - [Input] public bool input; - [Output] public bool output = true; + [Input, HideInInspector] public bool input; + [Output, HideInInspector] public bool output = true; public override bool led { get { return output; } } protected override void OnInputChanged() { diff --git a/Examples/LogicToy/Nodes/PulseNode.cs b/Examples/LogicToy/Nodes/PulseNode.cs index 894790f..44c0dcb 100644 --- a/Examples/LogicToy/Nodes/PulseNode.cs +++ b/Examples/LogicToy/Nodes/PulseNode.cs @@ -1,10 +1,11 @@ using UnityEngine; namespace XNode.Examples.LogicToy { - [NodeWidth(140)] + [NodeWidth(140), NodeTint(70,100,70)] public class PulseNode : LogicNode, ITimerTick { + [Space(-18)] public float interval = 1f; - [Output] public bool output; + [Output, HideInInspector] public bool output; public override bool led { get { return output; } } private float timer; diff --git a/Examples/LogicToy/Nodes/ToggleNode.cs b/Examples/LogicToy/Nodes/ToggleNode.cs index 61b70ba..ba71fa0 100644 --- a/Examples/LogicToy/Nodes/ToggleNode.cs +++ b/Examples/LogicToy/Nodes/ToggleNode.cs @@ -2,10 +2,10 @@ using UnityEngine; namespace XNode.Examples.LogicToy { - [NodeWidth(140)] + [NodeWidth(140), NodeTint(70,70,100)] public class ToggleNode : LogicNode { - [Input] public bool input; - [Output] public bool output; + [Input, HideInInspector] public bool input; + [Output, HideInInspector] public bool output; public override bool led { get { return output; } } protected override void OnInputChanged() {