This question was 
             closed Mar 26, 2016 at 08:04 PM by 
             Toon_Werawat for the following reason: 
             
 
            The question is answered, right answer was accepted
 
               Question by 
               Toon_Werawat · Sep 29, 2015 at 04:21 PM · 
                c#yieldwaitforsecondsienumeratorforeach  
              
 
              How to skip WaitForSeconds?
Hi
I'm try to skip WaitForSecond by press any keys. and skip. I'm search for it on Google. But it Java Script and it not work. I decide to ask. If anyone know.
Something like this?
 public IEnumerator TypingMessage(string message)
 {
     foreach (char letter in message.ToCharArray()) 
     {
         TypingUI.text += letter;
         if (Input.anyKey)
         {
             continue;
         }
         else 
         {
             yield return new WaitForSeconds (typingspeed);
         }
     }
     yield break;
 }
 //https://twitter.com/S0me_One_Else/status/981073875248103426
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by Jessespike · Sep 29, 2015 at 08:19 PM
Remove WaitForSeconds and use a loop that tracks time. Something like this:
 float elapsedTime = 0f;
 while (elapsedTime < typingspeed)
 {
      elapsedTime += Time.deltaTime;
      if (Input.anyKey) elapsedTime = typingspeed;
      else yield return null;
 }
Follow this Question
Related Questions
How to add multiple yield return new wait for seconds inside an IEnumerator? 1 Answer
Could not load source 'Coroutines.cs': No source available. 1 Answer
Trying to add a delay to an Instantiate in a For Loop 0 Answers
Unity WaitForSeconds Not Working Inside Update or a Loop 2 Answers
Trying to delay code, nothing works. 2 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                