mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-20 17:26:02 +08:00
Fixed incorrect position checking while zoomed
This commit is contained in:
parent
ac4fb1efd9
commit
4c6c10f15b
@ -137,7 +137,7 @@ public partial class NodeEditorWindow {
|
|||||||
Vector2 mousePos = Event.current.mousePosition;
|
Vector2 mousePos = Event.current.mousePosition;
|
||||||
//Get node position
|
//Get node position
|
||||||
Vector2 nodePos = GridToWindowPosition(node.position);
|
Vector2 nodePos = GridToWindowPosition(node.position);
|
||||||
Rect windowRect = new Rect(nodePos, new Vector2(/*Node width*/200 / zoom, 30 / zoom));
|
Rect windowRect = new Rect(nodePos, new Vector2(200 / zoom, 30 / zoom));
|
||||||
return windowRect.Contains(mousePos);
|
return windowRect.Contains(mousePos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -188,7 +188,7 @@ public partial class NodeEditorWindow {
|
|||||||
|
|
||||||
if (e.type != EventType.Layout) {
|
if (e.type != EventType.Layout) {
|
||||||
//Check if we are hovering this node
|
//Check if we are hovering this node
|
||||||
Vector2 nodeSize = GUILayoutUtility.GetLastRect().size / zoom;
|
Vector2 nodeSize = GUILayoutUtility.GetLastRect().size;
|
||||||
Rect windowRect = new Rect(nodePos, nodeSize);
|
Rect windowRect = new Rect(nodePos, nodeSize);
|
||||||
if (windowRect.Contains(mousePos)) hoveredNode = node;
|
if (windowRect.Contains(mousePos)) hoveredNode = node;
|
||||||
|
|
||||||
|
|||||||
@ -67,8 +67,7 @@ public partial class NodeEditorWindow : EditorWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Rect GridToWindowRect(Rect gridRect) {
|
public Rect GridToWindowRect(Rect gridRect) {
|
||||||
gridRect.position = GridToWindowPosition(gridRect.position);
|
gridRect.position = GridToWindowPositionNoClipped(gridRect.position);
|
||||||
gridRect.size /= zoom;
|
|
||||||
return gridRect;
|
return gridRect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user