mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-21 01:36:03 +08:00
Zoom System Fixes (#155)
- Due to the OnGUI method being called last to draw over everything else in the window, the GUI.Group being created in the new zoom system was also moving around the GUI elements created in the NodeGraphEditor OnGUI method.
This commit is contained in:
parent
c350c135ca
commit
3ba0b13c77
@ -12,6 +12,8 @@ namespace XNodeEditor {
|
|||||||
private List<XNode.Node> culledNodes;
|
private List<XNode.Node> culledNodes;
|
||||||
/// <summary> 19 if docked, 22 if not </summary>
|
/// <summary> 19 if docked, 22 if not </summary>
|
||||||
private int topPadding { get { return isDocked() ? 19 : 22; } }
|
private int topPadding { get { return isDocked() ? 19 : 22; } }
|
||||||
|
/// <summary> 0 if docked, 3 if not </summary>
|
||||||
|
private int leftPadding { get { return isDocked() ? 2 : 0; } }
|
||||||
/// <summary> Executed after all other window GUI. Useful if Zoom is ruining your day. Automatically resets after being run.</summary>
|
/// <summary> Executed after all other window GUI. Useful if Zoom is ruining your day. Automatically resets after being run.</summary>
|
||||||
public event Action onLateGUI;
|
public event Action onLateGUI;
|
||||||
|
|
||||||
@ -30,7 +32,7 @@ namespace XNodeEditor {
|
|||||||
DrawNodes();
|
DrawNodes();
|
||||||
DrawSelectionBox();
|
DrawSelectionBox();
|
||||||
DrawTooltip();
|
DrawTooltip();
|
||||||
graphEditor.OnGUI();
|
DrawGraphOnGUI();
|
||||||
|
|
||||||
// Run and reset onLateGUI
|
// Run and reset onLateGUI
|
||||||
if (onLateGUI != null) {
|
if (onLateGUI != null) {
|
||||||
@ -64,6 +66,16 @@ namespace XNodeEditor {
|
|||||||
GUI.BeginGroup(new Rect(0.0f, topPadding - (topPadding * zoom), Screen.width, Screen.height));
|
GUI.BeginGroup(new Rect(0.0f, topPadding - (topPadding * zoom), Screen.width, Screen.height));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary> Ends the GUI Group temporarily to draw any additional elements in the NodeGraphEditor. </summary>
|
||||||
|
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) {
|
public static Rect ScaleSizeBy(Rect rect, float scale, Vector2 pivotPoint) {
|
||||||
Rect result = rect;
|
Rect result = rect;
|
||||||
result.x -= pivotPoint.x;
|
result.x -= pivotPoint.x;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user