diff --git a/Editor/NodeEditor.cs b/Editor/NodeEditor.cs
index 8489478..ae3fdfa 100644
--- a/Editor/NodeEditor.cs
+++ b/Editor/NodeEditor.cs
@@ -118,6 +118,12 @@ namespace XNodeEditor {
else return 208;
}
+ public virtual int GetMinHeight()
+ {
+ Type type = target.GetType();
+ return type.TryGetAttributeHeight(out int height) ? height : 80;
+ }
+
/// Returns color for target node
public virtual Color GetTint() {
// Try get color from [NodeTint] attribute
diff --git a/Editor/NodeEditorGUI.cs b/Editor/NodeEditorGUI.cs
index d25a0e4..e5b99bf 100644
--- a/Editor/NodeEditorGUI.cs
+++ b/Editor/NodeEditorGUI.cs
@@ -397,6 +397,7 @@ namespace XNodeEditor {
if (Event.current.type != EventType.Layout && currentActivity == NodeActivity.DragGrid) selectedReroutes = selection;
}
+ private Rect lastRect;
private void DrawNodes() {
Event e = Event.current;
if (e.type == EventType.Layout) {
@@ -491,6 +492,14 @@ namespace XNodeEditor {
nodeEditor.OnHeaderGUI();
nodeEditor.OnBodyGUI();
+ //Fill remaining vertical space
+ if (e.type == EventType.Repaint)
+ {
+ lastRect = GUILayoutUtility.GetLastRect();
+ }
+ float remainingSpace = nodeEditor.GetMinHeight() - lastRect.yMax - 17;
+ if (remainingSpace > 0) GUILayout.Space(remainingSpace);
+
//If user changed a value, notify other scripts through onUpdateNode
if (EditorGUI.EndChangeCheck()) {
if (NodeEditor.onUpdateNode != null) NodeEditor.onUpdateNode(node);
diff --git a/Editor/NodeEditorReflection.cs b/Editor/NodeEditorReflection.cs
index fd75d05..420e37e 100644
--- a/Editor/NodeEditorReflection.cs
+++ b/Editor/NodeEditorReflection.cs
@@ -14,6 +14,7 @@ namespace XNodeEditor {
public static class NodeEditorReflection {
[NonSerialized] private static Dictionary nodeTint;
[NonSerialized] private static Dictionary nodeWidth;
+ [NonSerialized] private static Dictionary nodeHeight;
[NonSerialized] private static Dictionary nodeHeader;
/// All available node types
public static Type[] nodeTypes { get { return _nodeTypes != null ? _nodeTypes : _nodeTypes = GetNodeTypes(); } }
@@ -48,6 +49,14 @@ namespace XNodeEditor {
return nodeWidth.TryGetValue(nodeType, out width);
}
+ /// Get custom node heights defined with [NodeHeight(height)]
+ public static bool TryGetAttributeHeight(this Type nodeType, out int height) {
+ if (nodeHeight == null) {
+ CacheAttributes(ref nodeHeight, x => x.height);
+ }
+ return nodeHeight.TryGetValue(nodeType, out height);
+ }
+
/// Get custom node headers defined with [NodeHeader]
public static bool TryGetAttributeHeader(this Type nodeType, out GUIContent content)
{
diff --git a/Runtime/Flow/Events/StartNode.cs b/Runtime/Flow/Events/StartNode.cs
index 9d63bc3..d1949bf 100644
--- a/Runtime/Flow/Events/StartNode.cs
+++ b/Runtime/Flow/Events/StartNode.cs
@@ -1,6 +1,6 @@
namespace XNode.Flow.Events
{
- [NodeTint(1.0F,0.25F,0.25F), NodeWidth(75)]
+ [NodeTint(1.0F,0.25F,0.25F), NodeWidth(80), NodeHeight(80)]
public class StartNode : OutFlowNode
{
diff --git a/Runtime/Node.cs b/Runtime/Node.cs
index 079016f..8b289d6 100644
--- a/Runtime/Node.cs
+++ b/Runtime/Node.cs
@@ -389,6 +389,17 @@ namespace XNode {
}
}
+ /// Specify a minimum height for this node type
+ [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
+ public class NodeHeightAttribute : Attribute {
+ public int height;
+ /// Specify a minimum height for this node type
+ /// Minimum Height
+ public NodeHeightAttribute(int height) {
+ this.height = height;
+ }
+ }
+
/// Specify header GUIContent for this node type
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
public class NodeHeaderAttribute : Attribute