Good Day
I tried to understand the WaitForSeconds method trough the documentation and afterwards by looking here trough many questions but I still can’t get it to work.
My setup is as follows:
void FlipCardFaceUp(Card card_)
{
card_.isFaceUp = true;
aCardsFlipped.Add(card_);
if(aCardsFlipped.Count == 2)
{
playerCanClick = false;
StartCoroutine(WaitASec(2));
((Card)aCardsFlipped[0]).isFaceUp = false;
((Card)aCardsFlipped[1]).isFaceUp = false;
aCardsFlipped = new ArrayList();
playerCanClick = true;
}
}
IEnumerator WaitASec(float waitTime) {
yield return new WaitForSeconds(waitTime);
}
void OnGUI (){
if(GUILayout.Button((Texture)Resources.Load(card.GetImage()), GUILayout.Width(cardW)))
{
FlipCardFaceUp(card);
}
}
But It doesn’t work, the game doesn’t wait as if the function is not called. How exactly would I need to set it up so it will work?
If anyone can help me further with this I would appreciate it.