Esempio n. 1
0
 void OnGUI() // Not great to use onGui here, as it renders above everything.
 {
     if (isSelecting)
     {
         // Create a rect from both mouse positions
         var rect = RectangleDragSelection.GetScreenRect(playerCam, mousePosition1, mousePosition2);
         RectangleDragSelection.DrawScreenRect(rect, new Color(0.8f, 0.8f, 0.95f, 0.25f));
         RectangleDragSelection.DrawScreenRectBorder(rect, 2, new Color(0.8f, 0.8f, 0.95f));
     }
 }
 public static void DrawScreenRectBorder(Rect rect, float thickness, Color color)
 {
     // Top
     RectangleDragSelection.DrawScreenRect(new Rect(rect.xMin, rect.yMin, rect.width, thickness), color);
     // Left
     RectangleDragSelection.DrawScreenRect(new Rect(rect.xMin, rect.yMin, thickness, rect.height), color);
     // Right
     RectangleDragSelection.DrawScreenRect(new Rect(rect.xMax - thickness, rect.yMin, thickness, rect.height), color);
     // Bottom
     RectangleDragSelection.DrawScreenRect(new Rect(rect.xMin, rect.yMax - thickness, rect.width, thickness), color);
 }
Esempio n. 3
0
    public bool IsWithinSelectionBounds(GameObject controlObject)
    {
        if (!isSelecting)
        {
            return(false);
        }


        RaycastHit hit;

        if (Physics.Raycast(playerCam.ScreenPointToRay(Input.mousePosition), out hit, 200f, 5 << 9))
        {
            mousePosition2 = hit.point;
        }
        Bounds viewportBounds = RectangleDragSelection.GetViewportBounds(playerCam, mousePosition1, mousePosition2);

        return(viewportBounds.Contains(playerCam.WorldToViewportPoint(controlObject.transform.position)));
    }