private void SortList() { List <string> cardNames = new List <string> (); framesToWait = true; foreach (GameObject findedPanelOb in PanelsInDeckList) { cardDescStruct newCard = new cardDescStruct(); CardPanel findedPanel = findedPanelOb.GetComponent <CardPanel> (); newCard.CardName = findedPanel.PanelCardName; if (findedPanel.Card != null) { newCard.Card = findedPanel.Card; } newCard.CardsNumber = findedPanel.CardsNumber; PanelsInDeckCards.Add(newCard); cardNames.Add(findedPanel.PanelCardName); Destroy(findedPanel.PrevCard); findedPanel.DestroyPanelOnly(); } PanelsInDeckList.Clear(); cardNames = CardsBaseComponent.SortCardsList(cardNames); foreach (string cardName in cardNames) { GameObject panel = Instantiate(CardPanel); CardPanel panelComp = panel.GetComponent <CardPanel> (); panel.transform.SetParent(CardsInDeckTable, false); panelComp.PanelInDeck = true; foreach (cardDescStruct cardStOb in PanelsInDeckCards) { if (string.Compare(cardStOb.CardName, cardName) == 0) { panelComp.KeepCardPosition = false; panelComp.CardPosReached = false; if (cardStOb.Card != null) { panelComp.AddCard(cardStOb.Card); } panelComp.PanelCardName = cardStOb.CardName; panelComp.CardsNumber = cardStOb.CardsNumber; panelComp.RefreshCardsNumber(); break; } } PanelsInDeckList.Add(panel); } PanelsInDeckCards.Clear(); }