void ChooseCard(TarotCardData card, Button button) { if (gameRunner.cardsSelectedToDeal.Contains(card.order)) { // this card is already selected; remove it! Debug.Log("removing card " + card.name); button.image.color = cardButtonDefaultColor; gameRunner.RemoveChosenCard(card); Destroy(deckOrderToSelectedCardButtonMap[card.order]); deckOrderToSelectedCardButtonMap.Remove(card.order); deckOrderToDeckCardButtonMap.Remove(card.order); MaybeEnableAllButtons(); } else { Debug.Log("choosing card " + card.name); button.interactable = false; gameRunner.ChooseCard(card); deckOrderToDeckCardButtonMap.Add(card.order, button.gameObject); Button selectedCardButton = Instantiate(cardChooseButtonPrefab); selectedCardButton.transform.SetParent(chosenCardsList); selectedCardButton.image.color = cardButtonSelectedColor; TextMeshProUGUI textComp = null; textComp = selectedCardButton.GetComponentInChildren <TextMeshProUGUI>(); selectedCardButton.onClick.AddListener(() => ChooseCard(card, selectedCardButton)); if (textComp) { textComp.text = card.cardName; } deckOrderToSelectedCardButtonMap.Add(card.order, selectedCardButton.gameObject); MaybeDisableAllButtons(); } }