diff --git a/Scripts/Editor/NodeEditor.cs b/Scripts/Editor/NodeEditor.cs
index ba5a7f2..7976904 100644
--- a/Scripts/Editor/NodeEditor.cs
+++ b/Scripts/Editor/NodeEditor.cs
@@ -31,7 +31,7 @@ namespace XNodeEditor
public virtual void OnHeaderGUI()
{
- GUILayout.Label(target.name, NodeEditorResources.styles.nodeHeaderLabel, GUILayout.Height(30));
+ GUILayout.Label(target.name, NodeEditorResources.styles.nodeHeaderLabel);
}
/// Draws standard field editors for all public fields
diff --git a/Scripts/Editor/NodeEditorAction.cs b/Scripts/Editor/NodeEditorAction.cs
index b8ef971..63682c9 100644
--- a/Scripts/Editor/NodeEditorAction.cs
+++ b/Scripts/Editor/NodeEditorAction.cs
@@ -918,7 +918,8 @@ namespace XNodeEditor
width = 200;
}
- Rect windowRect = new Rect(nodePos, new Vector2(width / zoom, 30 / zoom));
+ Rect windowRect = new Rect(nodePos, new Vector2(width / zoom, NodeEditor.GetEditor(node, current)
+ .GetHeaderStyle().fixedHeight / zoom));
return windowRect.Contains(mousePos);
}
diff --git a/Scripts/Editor/NodeEditorGUI.cs b/Scripts/Editor/NodeEditorGUI.cs
index a3f7c07..169ed38 100755
--- a/Scripts/Editor/NodeEditorGUI.cs
+++ b/Scripts/Editor/NodeEditorGUI.cs
@@ -688,12 +688,12 @@ namespace XNodeEditor
if (selected)
{
- GUIStyle style = new GUIStyle(nodeEditor.GetBodyStyle());
+ GUIStyle styleBody = new GUIStyle(nodeEditor.GetBodyStyle());
GUIStyle highlightStyle = new GUIStyle(nodeEditor.GetBodyHighlightStyle());
- highlightStyle.padding = style.padding;
- style.padding = new RectOffset();
+ highlightStyle.padding = styleBody.padding;
+ styleBody.padding = new RectOffset();
GUI.color = nodeEditor.GetTint();
- GUILayout.BeginVertical(style);
+ GUILayout.BeginVertical(styleBody);
GUI.color = NodeEditorPreferences.GetSettings().highlightColor;
GUILayout.BeginVertical(new GUIStyle(highlightStyle));
}
@@ -706,22 +706,21 @@ namespace XNodeEditor
EditorGUI.BeginChangeCheck();
//Draw node contents
+ GUI.color = nodeEditor.GetHeaderColor();
+ GUIStyle styleHeader = new GUIStyle(nodeEditor.GetHeaderStyle());
+ GUILayout.BeginVertical(styleHeader);
+ GUI.color = guiColor;
if (currentActivity == NodeActivity.Renaming && Selection.activeObject == node)
{
RenameTextField.current.DrawRenameTextField();
}
else
{
- GUI.color = nodeEditor.GetHeaderColor();
- GUIStyle style = new GUIStyle(nodeEditor.GetHeaderStyle());
- GUILayout.BeginVertical(style);
-
- GUI.color = guiColor;
nodeEditor.OnHeaderGUI();
-
- GUILayout.EndVertical();
}
+ GUILayout.EndVertical();
+
GUI.color = nodeEditor.GetBodyColor();
GUIStyle bodyStyle = new GUIStyle(nodeEditor.GetBodyStyle());
GUILayout.BeginVertical(bodyStyle);
diff --git a/Scripts/Editor/NodeEditorPreferences.cs b/Scripts/Editor/NodeEditorPreferences.cs
index 3090676..9141e6f 100644
--- a/Scripts/Editor/NodeEditorPreferences.cs
+++ b/Scripts/Editor/NodeEditorPreferences.cs
@@ -71,6 +71,8 @@ namespace XNodeEditor
public Color32 bgPortsColor = new Color32(65, 67, 70, 255);
public Color32 bgBodyColor = new Color32(65, 67, 70, 255);
public Color32 highlightColor = new Color32(255, 255, 255, 255);
+ public Color32 resizeIconColor = new Color32(255, 255, 255, 26);
+ public Color32 resizeIconHoverColor = new Color32(255, 255, 255, 100);
public bool gridSnap = true;
public bool autoSave = true;
public bool openOnCreate = true;
@@ -276,6 +278,9 @@ namespace XNodeEditor
settings.bgHeaderColor = EditorGUILayout.ColorField("Header Background", settings.bgHeaderColor);
settings.bgPortsColor = EditorGUILayout.ColorField("Ports Background", settings.bgPortsColor);
settings.bgBodyColor = EditorGUILayout.ColorField("Body Background", settings.bgBodyColor);
+ settings.resizeIconColor = EditorGUILayout.ColorField("Resize Icon Color", settings.resizeIconColor);
+ settings.resizeIconHoverColor =
+ EditorGUILayout.ColorField("Resize Icon Hover Color", settings.resizeIconHoverColor);
settings.highlightColor = EditorGUILayout.ColorField("Selection", settings.highlightColor);
EditorGUILayout.Space();
settings.noodlePath = (NoodlePath)EditorGUILayout.EnumPopup("Noodle path", settings.noodlePath);
diff --git a/Scripts/Editor/NodeEditorResources.cs b/Scripts/Editor/NodeEditorResources.cs
index 7c7be4e..5f8ed33 100644
--- a/Scripts/Editor/NodeEditorResources.cs
+++ b/Scripts/Editor/NodeEditorResources.cs
@@ -64,14 +64,15 @@ namespace XNodeEditor
nodeHeaderLabel = new GUIStyle();
nodeHeaderLabel.alignment = TextAnchor.MiddleCenter;
nodeHeaderLabel.fontStyle = FontStyle.Bold;
+ nodeHeaderLabel.stretchHeight = true;
nodeHeaderLabel.normal.textColor = Color.white;
nodeHeaderLabelRename = new GUIStyle(GUI.skin.textField);
nodeHeaderLabelRename.alignment = TextAnchor.MiddleCenter;
nodeHeaderLabelRename.fontStyle = FontStyle.Bold;
+ nodeHeaderLabelRename.stretchHeight = true;
nodeHeaderLabelRename.normal.textColor = Color.white;
- nodeHeaderLabelRename.fixedHeight = 18;
- nodeHeaderLabelRename.margin = new RectOffset(5, 5, 10, 8);
+ nodeHeaderLabelRename.margin = new RectOffset(24, 24, 8, 2);
nodePadding = new GUIStyle();
nodePadding.padding = new RectOffset(16, 16, 3, 16);
@@ -79,8 +80,8 @@ namespace XNodeEditor
nodeHeader = new GUIStyle();
nodeHeader.normal.background = NodeEditorResources.nodeHeader;
nodeHeader.border = new RectOffset(32, 32, 16, 0);
- // nodeHeader.fixedHeight = 27;
- nodeHeader.padding = new RectOffset(0, 0, 1, 0);
+ nodeHeader.fixedHeight = 28;
+ nodeHeader.padding = new RectOffset(0, 0, 6, 0);
// nodeHeader.padding = new RectOffset(16, 16, 3, 16);
nodePorts = new GUIStyle();
diff --git a/Scripts/Editor/NodeGroupEditor.cs b/Scripts/Editor/NodeGroupEditor.cs
index f23a1bf..7c3816d 100644
--- a/Scripts/Editor/NodeGroupEditor.cs
+++ b/Scripts/Editor/NodeGroupEditor.cs
@@ -16,6 +16,7 @@ namespace XNodeEditor.NodeGroups
_corner != null ? _corner : _corner = Resources.Load("xnode_corner");
private static Texture2D _corner;
private bool _isResizing;
+ private bool _isResizeHovering;
private Vector2 _size;
private float _currentHeight;
private Vector2 _draggingOffset;
@@ -26,17 +27,24 @@ namespace XNodeEditor.NodeGroups
private const int mouseRectMargin = 30;
private GUIStyle headerStyle;
+ private GUIStyle headerLabelStyle;
public override void OnCreate()
{
_currentHeight = group.height;
- headerStyle = new GUIStyle(NodeEditorResources.styles.nodeHeaderLabel);
- headerStyle.fontSize = 18;
+ headerLabelStyle = new GUIStyle(NodeEditorResources.styles.nodeHeaderLabel);
+ headerLabelStyle.fontSize = 24;
+
+ headerStyle = new GUIStyle(NodeEditorResources.styles.nodeHeader);
+ headerStyle.fixedHeight += 18;
}
public override void OnHeaderGUI()
{
- GUILayout.Label(target.name, headerStyle, GUILayout.Height(30));
+ Color initColor = GUI.contentColor;
+ GUI.contentColor = new Color(0.6f, 0.6f, 0.6f, 1.0f);
+ GUILayout.Label(target.name, headerLabelStyle);
+ GUI.contentColor = initColor;
}
public override void OnBodyGUI()
@@ -45,11 +53,37 @@ namespace XNodeEditor.NodeGroups
Event e = Event.current;
switch (e.type)
{
+ case EventType.MouseMove:
+ if (NodeEditorWindow.current.nodeSizes.TryGetValue(target, out _size))
+ {
+ bool initHovering = _isResizeHovering;
+ // Mouse position checking is in node local space
+ Rect lowerRight = new Rect(_size.x - (mouseRectMargin + mouseRectPadding),
+ _size.y - (mouseRectMargin + mouseRectPadding), mouseRectMargin, mouseRectMargin);
+ if (lowerRight.Contains(e.mousePosition))
+ {
+ _isResizeHovering = true;
+ }
+ else
+ {
+ _isResizeHovering = false;
+ }
+
+ if (initHovering != _isResizeHovering)
+ {
+ NodeEditorWindow.current.Repaint();
+ }
+ }
+
+ break;
case EventType.MouseDrag:
if (_isResizing)
{
- group.width = Mathf.Max(200, (int)e.mousePosition.x + (int)_draggingOffset.x + 16);
- group.height = Mathf.Max(100, (int)e.mousePosition.y + (int)_draggingOffset.y - 34);
+ group.width = (int)Mathf.Max(200,
+ e.mousePosition.x + _draggingOffset.x + (mouseRectMargin + mouseRectPadding));
+ // magic numbers - otherwise resizing will jump vertically.
+ group.height = (int)Mathf.Max(100,
+ e.mousePosition.y + _draggingOffset.y - (31 + (30 - mouseRectMargin)));
_currentHeight = group.height;
NodeEditorWindow.current.Repaint();
}
@@ -78,8 +112,7 @@ namespace XNodeEditor.NodeGroups
if (lowerRight.Contains(e.mousePosition))
{
_isResizing = true;
- _draggingOffset = _size - e.mousePosition - new Vector2(GetBodyStyle().padding.right,
- GetBodyStyle().padding.bottom);
+ _draggingOffset = lowerRight.position - e.mousePosition;
}
}
@@ -166,17 +199,23 @@ namespace XNodeEditor.NodeGroups
}
GUILayout.Space(_currentHeight);
- GUI.DrawTexture(new Rect(group.width - 34, group.height + 16, 24, 24), corner);
- }
- public override void OnRenameActive()
- {
- _currentHeight += 30 - NodeEditorResources.styles.nodeHeaderLabelRename.fixedHeight -
- NodeEditorResources.styles.nodeHeaderLabelRename.margin.top +
- NodeEditorResources.styles.nodeHeaderLabelRename.margin.bottom / 2;
+ if (NodeEditorWindow.current.nodeSizes.TryGetValue(target, out _size))
+ {
+ Color initColor = GUI.color;
+ GUI.color = _isResizeHovering
+ ? NodeEditorPreferences.GetSettings().resizeIconHoverColor
+ : NodeEditorPreferences.GetSettings().resizeIconColor;
+ GUI.DrawTexture(
+ new Rect(_size.x - (mouseRectMargin + mouseRectPadding),
+ _size.y - (mouseRectMargin + mouseRectPadding),
+ 24,
+ 24),
+ corner);
+ GUI.color = initColor;
+ }
}
-
public override void OnRenameDeactive()
{
_currentHeight = group.height;
@@ -187,11 +226,16 @@ namespace XNodeEditor.NodeGroups
return group.width;
}
- public override GUIStyle GetHeaderLabelStyle()
+ public override GUIStyle GetHeaderStyle()
{
return headerStyle;
}
+ public override GUIStyle GetHeaderLabelStyle()
+ {
+ return headerLabelStyle;
+ }
+
public static void AddMouseRect(Rect rect, MouseCursor mouseCursor)
{
EditorGUIUtility.AddCursorRect(rect, mouseCursor);
diff --git a/Scripts/Editor/RenameTextField.cs b/Scripts/Editor/RenameTextField.cs
index 95138f3..8bd701b 100644
--- a/Scripts/Editor/RenameTextField.cs
+++ b/Scripts/Editor/RenameTextField.cs
@@ -38,6 +38,10 @@ namespace XNodeEditor
GUIStyle stylesNodeHeaderRename = NodeEditorResources.styles.nodeHeaderLabelRename;
stylesNodeHeaderRename.fontSize =
NodeEditor.GetEditor((Node)target, NodeEditorWindow.current).GetHeaderLabelStyle().fontSize;
+ stylesNodeHeaderRename.fixedHeight = NodeEditor.GetEditor((Node)target, NodeEditorWindow.current)
+ .GetHeaderLabelStyle().fixedHeight;
+ stylesNodeHeaderRename.padding = NodeEditor.GetEditor((Node)target, NodeEditorWindow.current)
+ .GetHeaderLabelStyle().padding;
input = GUILayout.TextField(input, stylesNodeHeaderRename);
EditorGUI.FocusTextInControl(inputControlName);
diff --git a/Scripts/Editor/Resources/xnode_corner.png b/Scripts/Editor/Resources/xnode_corner.png
index 12d25fa..31fbf1c 100644
Binary files a/Scripts/Editor/Resources/xnode_corner.png and b/Scripts/Editor/Resources/xnode_corner.png differ
diff --git a/Scripts/Editor/Resources/xnode_corner.png.meta b/Scripts/Editor/Resources/xnode_corner.png.meta
index 5b45fe5..fd8222b 100644
--- a/Scripts/Editor/Resources/xnode_corner.png.meta
+++ b/Scripts/Editor/Resources/xnode_corner.png.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: 0babe8a4377248fcacd576e5da1a27e5
+guid: d129eb4a5ff1c8a40a23ef0e54de1fa9
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
@@ -63,16 +63,16 @@ TextureImporter:
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
- applyGammaDecoding: 1
+ applyGammaDecoding: 0
swizzle: 50462976
- cookieLightType: 2
+ cookieLightType: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
- textureCompression: 1
+ textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
@@ -85,7 +85,7 @@ TextureImporter:
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
- textureCompression: 0
+ textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
@@ -98,7 +98,7 @@ TextureImporter:
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
- textureCompression: 0
+ textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
@@ -111,7 +111,7 @@ TextureImporter:
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
- textureCompression: 0
+ textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
diff --git a/Scripts/Editor/Resources/xnode_corner.xcf b/Scripts/Editor/Resources/xnode_corner.xcf
new file mode 100644
index 0000000..fb5990d
Binary files /dev/null and b/Scripts/Editor/Resources/xnode_corner.xcf differ
diff --git a/Scripts/Editor/Resources/xnode_corner.xcf.meta b/Scripts/Editor/Resources/xnode_corner.xcf.meta
new file mode 100644
index 0000000..e0866e2
--- /dev/null
+++ b/Scripts/Editor/Resources/xnode_corner.xcf.meta
@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: fe6a85593b08b0e41bef27ac9562c228
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Scripts/NodeGroup.cs b/Scripts/NodeGroup.cs
index 85d68bd..4cf7929 100644
--- a/Scripts/NodeGroup.cs
+++ b/Scripts/NodeGroup.cs
@@ -2,8 +2,8 @@
namespace XNode
{
- [NodeColorHeader(0.2f, 0.2f, 0.2f, 0.5f)]
- [NodeColorBody(0.25f, 0.25f, 0.25f, 0.35f)]
+ [NodeColorHeader(0.1f, 0.1f, 0.1f, 0.35f)]
+ [NodeColorBody(0.1f, 0.1f, 0.1f, 0.35f)]
[CreateNodeMenu("Group")]
public class NodeGroup : Node
{