In my script, it’s supposed to load a new level, then instantiate a prefab. The level loading works, but it ALWAYS tries to do the other stuff before changing the level, and the prefab goes away.
function Update () {
if (//some stuff//) {
displayKickDialogue();
}
}
function displayKickDialogue () {
Application.LoadLevel("titlemenu");
//Instantiate(Resources.Load("KickDialogue"));
Screen.showCursor = true;
}
function OnLevelWasLoaded () {
Instantiate(Resources.Load("KickDialogue"));
}
I also tried using OnLevelWasLoaded and it still shows the thing before loading the new level.