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?

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.