public void HandleSelectionSingle(ISelectableUI source, bool value) { if (!value && selectedItem == source && enableUnselecting) { Clear(); } else if (value) { if (selectedItems.Contains(source)) { Debug.Log($"already selected {source.name}"); } else { if (selectedItem != null) { Debug.Log($" triggering isselected false on {selectedItem.name}"); selectedItem.isSelected = false; } selectedItem = source; _selectedItems.Clear(); _selectedItems.Add(source); selectedItem.isSelected = true; onSelectionChanged.Invoke(); } } selectedItemCount = selectedItem == null ? 0 : 1; onSelectionChanged.Invoke(); }
public void HandleSelectionMulti(ISelectableUI source, bool value) { if (!value) { if (selectedItems.Contains(source)) { if (enableUnselecting || selectedItems.Count > 1) { selectedItems.Remove(source); source.isSelected = false; } } else { Debug.Log("item was not selected {source.name}", source.gameObject); } } else { if (selectedItems.Contains(source)) { Debug.Log($"item was selected already {source.name}", source.gameObject); } else { selectedItems.Add(source); source.isSelected = true; } } selectedItemCount = selectedItems.Count; onSelectionChanged.Invoke(); }
public void ToggleSelectionTo(ISelectableUI selection, string inGroup) { //Debugging.PrintDictionary(selectionToggleGroups); if (GetSelectedItemFromGroup(inGroup) != null) { if (!GetSelectedItemFromGroup(inGroup).Equals(null)) { if (GetSelectedItemFromGroup(inGroup) != selection) { print(GetSelectedItemFromGroup(inGroup)); GetSelectedItemFromGroup(inGroup).DeselectSelf(); selectionToggleGroups[inGroup] = selection; if (selection != null) { selection.SelectSelf(); } } else { selection.SelectSelf(); } } else { selectionToggleGroups[inGroup] = selection; selection.SelectSelf(); } } else { selectionToggleGroups[inGroup] = selection; selection.SelectSelf(); } }
public void HandleSelection(ISelectableUI source, bool value) { if (selectionMode == SelectionMode.Single) { HandleSelectionSingle(source, value); } if (selectionMode == SelectionMode.Multiple) { HandleSelectionMulti(source, value); } }