diff --git a/Scripts/Editor/NodeEditorGUI.cs b/Scripts/Editor/NodeEditorGUI.cs index aa88505..7447b8a 100644 --- a/Scripts/Editor/NodeEditorGUI.cs +++ b/Scripts/Editor/NodeEditorGUI.cs @@ -12,6 +12,8 @@ namespace XNodeEditor { private List culledNodes; /// 19 if docked, 22 if not private int topPadding { get { return isDocked() ? 19 : 22; } } + /// 0 if docked, 3 if not + private int leftPadding { get { return isDocked() ? 2 : 0; } } /// Executed after all other window GUI. Useful if Zoom is ruining your day. Automatically resets after being run. public event Action onLateGUI; @@ -30,7 +32,7 @@ namespace XNodeEditor { DrawNodes(); DrawSelectionBox(); DrawTooltip(); - graphEditor.OnGUI(); + DrawGraphOnGUI(); // Run and reset onLateGUI if (onLateGUI != null) { @@ -64,6 +66,16 @@ namespace XNodeEditor { GUI.BeginGroup(new Rect(0.0f, topPadding - (topPadding * zoom), Screen.width, Screen.height)); } + /// Ends the GUI Group temporarily to draw any additional elements in the NodeGraphEditor. + private void DrawGraphOnGUI() { + GUI.EndGroup(); + Rect rect = new Rect(new Vector2(leftPadding, topPadding), new Vector2(Screen.width, Screen.height)); + GUI.BeginGroup(rect); + graphEditor.OnGUI(); + GUI.EndGroup(); + GUI.BeginGroup(new Rect(0.0f, topPadding - (topPadding * zoom), Screen.width, Screen.height)); + } + public static Rect ScaleSizeBy(Rect rect, float scale, Vector2 pivotPoint) { Rect result = rect; result.x -= pivotPoint.x;