public static void DrawScreenRectBorder(Rect rect, float thickness, Color color) { BoxSelectionGUI.DrawBox(new Rect(rect.xMin, rect.yMin, rect.width, thickness), color); BoxSelectionGUI.DrawBox(new Rect(rect.xMin, rect.yMin, thickness, rect.height), color); BoxSelectionGUI.DrawBox(new Rect(rect.xMax - thickness, rect.yMin, thickness, rect.height), color); BoxSelectionGUI.DrawBox(new Rect(rect.xMin, rect.yMax - thickness, rect.width, thickness), color); }
void OnGUI() { if (isSelecting) { Rect rect = BoxSelectionGUI.GetScreenRect(startingPos, Input.mousePosition); BoxSelectionGUI.DrawBox(rect, new Color(.8f, .8f, .95f, .25f)); BoxSelectionGUI.DrawScreenRectBorder(rect, 2, new Color(.8f, .8f, .95f, .25f)); } }
public bool IsWithinSelectionBounds(GameObject army) { if (!isSelecting) { return(false); } Camera cam = Camera.main; Bounds bounds = BoxSelectionGUI.GetViewportBounds(cam, startingPos, Input.mousePosition); if (bounds.Contains(cam.WorldToViewportPoint(army.transform.position))) { Debug.Log(army.name + " is in the selection area"); } return(bounds.Contains(cam.WorldToViewportPoint(army.transform.position))); }