title: Make GUI.Box stay for 3 seconds
body: <p>I'm working on a project in Unity using C# scripting. The GUI.Box will appear at the top the screen. The box will disappear when the player leaves the spot. How can I make the box stay there for an additional 3 seconds after the player leaves the designated spot?</p>
  
  <p>Danpe's code corrected (working code):</p>
  
  <pre><code>bool shown = false;
  
  void OnGUI () {
  if (car.transform.position.y&gt;=43 &amp;&amp; car.transform.position.y&lt;=44)
  {
      shown = true;
  }
  else if (shown)
  {
      StartCoroutine(DisapearBoxAfter(3.0f)); 
  }
  if(shown) 
  {
      GUI.Box(new Rect((Screen.width/2)-200,0,400,30) , "King of the hill");
  }
  }
  
  IEnumerator DisapearBoxAfter(float waitTime) { 
  // suspend execution for waitTime seconds
  yield return new WaitForSeconds(waitTime);
  shown = false;
  }
  
  
  
  
  void Update () {
      OnGUI ();
  }
  </code></pre>