GroupSelectionManager is a singleton class that manages groups of selectable objects in a game system. It provides functionality to create, modify, and select groups of objects.
Usage Example
// Get reference to GroupSelectionManagervargroupManager=GroupSelectionManager.Instance;// Save current selection to group 1groupManager.TrySave(1);// Add more selections to group 1groupManager.AddSelectionsAt(1);// Select group 1groupManager.SelectGroup(1);// Remove group 1groupManager.RemoveGroup(1);
Properties
Groups
CurrentGroupIndex
Methods
TrySave
Saves the current selection or specified selectables to a group.
Parameters:
groupIdx: The index where the group will be saved
selectables: Collection of selectable objects to save
Returns: true if save was successful, false otherwise
AddSelectionsAt
Adds current selections or specified selectables to an existing group.
Parameters:
groupIdx: The target group index
selectables: Collection of selectable objects to add
Returns: Number of items successfully added
RemoveSelectionsAt
Removes current selections or specified selectables from a group.
Parameters:
groupIdx: The target group index
selectables: Collection of selectable objects to remove
Returns: Number of items successfully removed
SelectGroup
Selects all objects in the specified group.
Parameters:
groupIdx: The index of the group to select
Returns: true if group was successfully selected, false otherwise
RemoveGroup
Removes an entire group.
Parameters:
groupIdx: The index of the group to remove
Returns: true if group was successfully removed, false otherwise
HasGroup
Checks if a group exists and contains any selectables.
Parameters:
groupIdx: The group index to check
Returns: true if group exists and is not empty, false otherwise
ContainAtGroup
Checks if a specific selectable object exists in a group.
Parameters:
groupIdx: The group index to check
selectable: The selectable object to look for
Returns: true if the object exists in the group, false otherwise
IsGroupSelected
Checks if a specific group is currently selected.
Parameters:
groupIdx: The group index to check
Returns: true if the specified group is currently selected, false otherwise
Events
The class listens to the following events:
Dependencies
Inherits from SingletonMonoBehaviour<SelectionGroupManager>