//On GUI, used to draw group selects private void OnGUI() { //check if group selecting if (groupSelect) { //draw selection rectangle Rect r = GroupSelectUtil.GetGroupRect(initGroupPos, controls.InputPosition()); GroupSelectUtil.DrawGroupRect(r, groupSelectColor); GroupSelectUtil.DrawGroupRectBorder(r, groupSelectBorderColor, 2); } }
//Draw border rect public static void DrawGroupRectBorder(Rect rect, Color color, float size) { //Top GroupSelectUtil.DrawGroupRect(new Rect(rect.xMin, rect.yMin, rect.width, size), color); //Left GroupSelectUtil.DrawGroupRect(new Rect(rect.xMin, rect.yMin, size, rect.height), color); //Right GroupSelectUtil.DrawGroupRect(new Rect(rect.xMax - size, rect.yMin, size, rect.height), color); //Bottom GroupSelectUtil.DrawGroupRect(new Rect(rect.xMin, rect.yMax - size, rect.width, size), color); }
public bool UnitInBounds(Transform t) { return(GroupSelectUtil.GetRectBounds(initGroupPos, controls.InputPosition()).Contains(Camera.main.WorldToViewportPoint(t.position))); }