Question by 
               Mac_Gray · Apr 29, 2017 at 05:40 AM · 
                delayscene-switching  
              
 
              How do I change scenes with a delay after pressing a button?
For example, if I hit the escape key it waits 2 seconds and then goes to the option scene. I am coding in C#.
               Comment
              
 
               
              Answer by PizzaPie · Apr 29, 2017 at 05:08 PM
 Using UnityEngine.SceneManagement;
 
 //....
 IEnumerator ChangeScene(int index,float delay = 2f)
     {
          yield return new WaitForSeconds(delay);
          SceneManager.LoadScene(index);
     }
     void Update()
     {
         if (Input.GetKeyDown(KeyCode.Escape))
         {
             StartCoroutine(ChangeScene(2));             //Change the number to the Scene index you want to load
         }
     }
 
               Or you could use Invoke().
Your answer
 
             Follow this Question
Related Questions
PLEASE HELP!!! 0 Answers
,delay after dying and going back to main menu (new scene) 0 Answers
Preloading all scenes to remove scene switch delay 1 Answer
Player keeps moving after key up 1 Answer
Fix sound delay 6 Answers