Hello. I send a request to my server and want to wait for an answer before continuing my function. My problem is my algorithm is not waiting in any way. It is just ignoring my Coroutine and my while function. My structure:
IEnumerator startGame(){ //<--- is a started coroutine
//... code for doing some stuff
getCard();
//--- other code
}
void getCard(){
//..Code
SendRequest();
startWait();
//..more Code
}
IEnumerator startWait(){
Debug.Log("start bla");
yield return StartCoroutine ("bla");
Debug.Log("bla finished");
}
//bla is checking if the stuff I receive from the server is fitting
//the one I am waiting for. if it is fitting break the while loop
IEnumerator bla(){
Debug.Log ("Start waiting");
waitForReply = true;
while(waitForReply){
//code for checking my received strings....
yield return null;
}
Debug.Log ("Done");
}
First I tried to wait for my reply in the startWait-Function but to see how deep he is going down in this algorithm I used one more function.
It is running into startWait. But in the moment when it is in startWait it is leaving startWait already without even reaching my Debug.Log.
Does anyone know what I am doing wrong or is there an even better way to do it?
Any idea or hint can be helpful. Thank you in advance.