コード例 #1
0
    void CompleteSelection_Multi()
    {
        Vector2 minVect = unitSelectionArea.anchoredPosition - (unitSelectionArea.sizeDelta / 2);
        Vector2 maxVect = unitSelectionArea.anchoredPosition + (unitSelectionArea.sizeDelta / 2);

        foreach (var unit in player.GetUnits())
        {
            // aleady selected?
            if (SelectedUnits.Contains(unit))
            {
                continue;
            }

            Vector3 screenPosition = mainCamera.WorldToScreenPoint(unit.transform.position);
            if (screenPosition.x > minVect.x &&
                screenPosition.x < maxVect.x &&
                screenPosition.y > minVect.y &&
                screenPosition.y < maxVect.y)
            {
                SelectedUnits.Add(unit);
                unit.Select();
            }
        }
    }