private void DeselectAllUnits() { if (_selectedBuilding) { DeselectBuilding(); } if (SelectedUnits.Count > 0) { SelectedUnits.RemoveAll(u => u == null); SelectedUnits.ForEach(delegate(GameObject unit) { unit.GetComponent <Unit>().Deselect(); }); SelectedUnits.Clear(); UpdateSelectedUnits(); } }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> // /// </summary> public void DeselectAllObjects() { // Set all objects to NOT selected foreach (var obj in SelectedWorldObjects) { obj.SetIsSelected(false); } foreach (var obj in SelectedUnits) { obj.SetIsSelected(false); } // Clear the list if (SelectedWorldObjects.Count > 0) { SelectedWorldObjects.Clear(); } if (SelectedUnits.Count > 0) { SelectedUnits.Clear(); } }
/// <summary> /// ONLY way to remove selection! /// </summary> public void ClearSelection() { SelectedUnits.ForEach(a => a.Deselect()); SelectedUnits.Clear(); }