/// <summary> /// Removes selection icon from tile and requeues it in object pool /// </summary> /// <param name="selection"></param> void RemoveSelection(Transform selection) { //Queue up removed selection to inactive pool InactiveSelectionObjects.Enqueue(SelectedObjects[selection]); //Set gameobject to inactive SelectedObjects[selection].SetActive(false); //Remove selection gameobject from active objects ActiveSelectionIconObjects.Remove(SelectedObjects[selection]); //Remove from select dictionary SelectedObjects.Remove(selection); }
/// <summary> /// Adds selection icon to tile and stores reference to it /// </summary> /// <param name="selection"></param> void AddSelection(Transform selection) { //Dequeue inactive object from queue GameObject newSelectionIcon = InactiveSelectionObjects.Dequeue(); //Set object to active in scene newSelectionIcon.SetActive(true); //Sets new object to correct position newSelectionIcon.transform.position = selection.position; //Add new object to dictionary SelectedObjects.Add(selection, newSelectionIcon); //Add to active selection list ActiveSelectionIconObjects.Add(newSelectionIcon); //Add tile to current tiles selected SelectedTiles.Add(selection.gameObject); }