Skip to content

Commit 332569b

Browse files
committed
feat: extract and expose screen rect and viewport bound functions
1 parent 999586b commit 332569b

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

Runtime/Scripts/UnitSelection.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public void OnSelectionEnd()
7070
public void DrawGUI(Vector3 cursorScreenPos)
7171
{
7272
// Create a rect from both cursor positions
73-
Rect rect = Utils.GetScreenRect(m_cursorPosition, cursorScreenPos);
73+
Rect rect = GetScreenRect(cursorScreenPos);
7474
Utils.DrawScreenRect(rect, style.fillColor);
7575
Utils.DrawScreenRectBorder(rect, style.thickness, style.edgeColor);
7676
}
@@ -82,11 +82,20 @@ public void SetObserver(in List<T> bufferToObserve)
8282

8383
public bool IsWithinSelectionBounds(Camera camera, GameObject gameObject, Vector3 cursorScreenPos)
8484
{
85-
Bounds viewportBounds =
86-
Utils.GetViewportBounds(camera, m_cursorPosition, cursorScreenPos);
85+
Bounds viewportBounds = GetViewportBounds(camera, cursorScreenPos);
8786

8887
return viewportBounds.Contains(
8988
camera.WorldToViewportPoint(gameObject.transform.position));
9089
}
90+
91+
public Rect GetScreenRect(Vector3 cursorScreenPo)
92+
{
93+
return Utils.GetScreenRect(m_cursorPosition, cursorScreenPo);
94+
}
95+
96+
public Bounds GetViewportBounds(Camera camera, Vector3 cursorScreenPos)
97+
{
98+
return Utils.GetViewportBounds(camera, m_cursorPosition, cursorScreenPos);
99+
}
91100
}
92101
}

0 commit comments

Comments
 (0)