Unity scripting issue w/ coroutines c#

I am using as coroutine so that something happens 2 seconds after another few things.

IEnumerator MyMethod()
{
Debug.Log ("Dead");
Destroy (PlayerSprite);
yield return new WaitForSeconds(2.0f);
Application.Loadlevel("Level 1")
Debug.Log("Loading level?");
}

Want I want this to do is send ‘dead’ and such, wait 2 seconds, and then reload the level with Application.LoadLevel. I call the coroutine later like this:

StartCoroutine(MyMethod());

The Debug.Log(“Dead”); is sent and everything before, but nothing after the 2 seconds happens, including the second Debug.Log! Anyone know what part I’m phrasing incorrectly? - JS

  1. Your line#6 is incorrectly written, it should be:

    Application.LoadLevel(“Level 1”);

  2. Make sure that you’ve added “Level 1” scene to your File=>Build Setting=>Scenes in build (just drag and drop your scene over there).

Now everything should work.

If it is the same level it should work even without step 2, but you’ll need to add it in the end anyway (for actual build).