Exemple #1
0
 void OnGUI()
 {
     if (isSelecting && canSelect)
     {
         // Create a rect from both mouse positions
         var rect = UnitSelectUtils.GetScreenRect(mousePosition1, Input.mousePosition);
         UnitSelectUtils.DrawScreenRect(rect, new Color(0.8f, 0.8f, 0.95f, 0.25f));
         UnitSelectUtils.DrawScreenRectBorder(rect, 2, new Color(0.8f, 0.8f, 0.95f));
     }
 }
Exemple #2
0
 public static void DrawScreenRectBorder(Rect rect, float thickness, Color color)
 {
     // Top
     UnitSelectUtils.DrawScreenRect(new Rect(rect.xMin, rect.yMin, rect.width, thickness), color);
     // Left
     UnitSelectUtils.DrawScreenRect(new Rect(rect.xMin, rect.yMin, thickness, rect.height), color);
     // Right
     UnitSelectUtils.DrawScreenRect(new Rect(rect.xMax - thickness, rect.yMin, thickness, rect.height), color);
     // Bottom
     UnitSelectUtils.DrawScreenRect(new Rect(rect.xMin, rect.yMax - thickness, rect.width, thickness), color);
 }
Exemple #3
0
    public bool IsWithinSelectionBounds(GameObject gameObject)
    {
        if (!isSelecting || !canSelect)
        {
            return(false);
        }

        Camera camera         = Camera.main;
        Bounds viewportBounds =
            UnitSelectUtils.GetViewportBounds(camera, mousePosition1, Input.mousePosition);

        return(viewportBounds.Contains(
                   camera.WorldToViewportPoint(gameObject.transform.position)));
    }