title: Is there a way to stay in a coroutine until a condition is met?
body: <p>I am trying to program a very simple dialogue system.  When a player gets a dialogue box, the box remains until they press a key.  Then a second dialogue box appears.  Again, they press a key, and so on.</p>
  
  <p>I am realizing, however, that my method of using coroutines doesn't work, because every dialogue box displays at once. Using a simplified version:</p>
  
  <pre><code>IEnumerator Test() {
          //Code that displays a message
          yield return StartCoroutine(WaitForKey(KeyCode.Space));
      }
  
      IEnumerator WaitForKey(KeyCode keyCode)
      {
          while (!Input.GetKeyDown(keyCode))
              yield return null;
      }
  
      void start(){
          StartCoroutine(Test());
          StartCoroutine(Test());
      }
  </code></pre>
  
  <p>The results of the above code is that two messages are displayed. Plus, they display immediately--once a condition is met, the process jumps from that courtine to the initiating, runs the next line of code, and periodically returns to the first coroutine to see if it has finished. </p>
  
  <p>How do I get one coroutine to finish before it continues with the rest of the code following it?</p>