im trying to only add a card to my hand if it doesnt already exist, this is the code i use:
public List playerHand = new List();
public void LoadCards ()
{
Debug.Log("Loading Cards!");
for (int i=0; i < this.transform.childCount;i++)
{
foreach (Card card in playerHand)
{
if (this.transform.GetChild(i).GetComponent() == card)
{
break;
}
}
playerHand.Add(this.transform.GetChild(i).GetComponent());
}
}
The problem is that my break just brings the loop back to the foreach, while i need it to go back to the for loop to make sure i dont add dublicate cards
↧