- Home /
Question by
yoshirotee · Sep 25, 2014 at 12:12 PM ·
c#touchstopcoroutine
Stopcoroutine by tapping screen
Hi, im making splash screen and enable player to skip it by tapping the screen.
StartCoroutine ("Splash");
while(!onSkip){
if(Input.touchCount == 1){
onSkip = true;
StopCoroutine("Splash");
Application.LoadLevel ("MainMenu");
}
}
However when I test it the editor become not responding. Is there any alternative method to accomplish this?
Comment
Best Answer
Answer by dmg0600 · Sep 25, 2014 at 12:15 PM
Add a yield in your while or it will run the while without stopping.
while(!onSkip){
if(Input.touchCount == 1){
onSkip = true;
StopCoroutine("Splash");
Application.LoadLevel ("MainMenu");
}
yield return null;
}
This way it will wait for the next frame to enter the next iteration of the while loop.