Пример #1
0
    private bool isBoxSelected()
    {
        Vector3 selectionPointPosition;

        for (int x = 0; x != selectionBox.Count; x++)
        {
            selectionPointPosition   = Camera.main.WorldToScreenPoint(selectionBox[x].transform.position);
            selectionPointPosition.y = SelectionBox.InvertMouseY(selectionPointPosition.y);

            if (SelectionBox.selection.Contains(selectionPointPosition))
            {
                addToSelectionGroup();

                return(true);
            }
        }

        return(false);
    }
Пример #2
0
 // Update is called once per frame
 void Update()
 {
     if (GetComponent <Unit>().meshRenderer.isVisible)
     {
         Vector3 camPos = Camera.main.WorldToScreenPoint(transform.position);
         camPos.y = SelectionBox.InvertMouseY(camPos.y);
         if (Input.GetMouseButtonUp(0))
         {
             selected = SelectionBox.selection.Contains(camPos);
             if (selected)
             {
                 Selected();
             }
         }
         else if (Input.GetMouseButton(0))
         {
             highlighted = SelectionBox.selection.Contains(camPos);
             if (highlighted)
             {
                 Highlight();
             }
         }
     }
 }