From 6758a1a7c4a2f01cbaa1caebaca74aee36585834 Mon Sep 17 00:00:00 2001 From: Thor Brigsted Date: Thu, 25 Jan 2018 12:42:35 +0100 Subject: [PATCH] Fixed box selection not working correctly when zoomed --- Scripts/Editor/NodeEditorGUI.cs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Scripts/Editor/NodeEditorGUI.cs b/Scripts/Editor/NodeEditorGUI.cs index fc28784..e3f8c4c 100644 --- a/Scripts/Editor/NodeEditorGUI.cs +++ b/Scripts/Editor/NodeEditorGUI.cs @@ -284,14 +284,11 @@ namespace XNodeEditor { //If dragging a selection box, add nodes inside to selection if (currentActivity == NodeActivity.DragGrid) { - Vector2 startPos = GridToWindowPosition(dragBoxStart); - Vector2 size = (mousePos - startPos) / zoom; - Rect r = new Rect(dragBoxStart, size); - Vector2 rpos = GridToWindowPosition(r.position); - if (size.x < 0) { rpos.x += size.x; size.x = Mathf.Abs(size.x); } - if (size.y < 0) { rpos.y += size.y; size.y = Mathf.Abs(size.y); } - r.position = rpos; - r.size = size; + Vector2 startPos = GridToWindowPositionNoClipped(dragBoxStart); + Vector2 size = mousePos - startPos; + if (size.x < 0) { startPos.x += size.x; size.x = Mathf.Abs(size.x); } + if (size.y < 0) { startPos.y += size.y; size.y = Mathf.Abs(size.y); } + Rect r = new Rect(startPos, size); if (windowRect.Overlaps(r)) preSelection.Add(node); }