public void RemoveCard(string cardName) { Debug.Log("Remove card from deck:" + cardName); DeckTableControllerComponent.RemoveCardFromDeck(CardsBaseComponent.GetIdByName(cardName).ToString()); CardsInDeckNames.Remove(cardName); foreach (GameObject findedPanelOb in PanelsInDeckList) { if (findedPanelOb != null) { CardPanel findedPanel = findedPanelOb.GetComponent <CardPanel> (); if (findedPanel != null) { if (findedPanel.PanelCardName == cardName) { findedPanel.CardsNumber--; findedPanel.RefreshCardsNumber(); if (findedPanel.CardsNumber < 1) { findedPanel.DestroyPanel(); PanelsInDeckList.Remove(findedPanelOb); break; } } } else { CardViewPanel panel = findedPanelOb.GetComponent <CardViewPanel> (); if (panel != null) { if (panel.PanelPawn.GetComponent <Pawn> ().Name == cardName) { PanelsInDeckList.Remove(findedPanelOb); //Destroy (findedPanelOb); break; } } } } } }