I have an introductional video as the first level of my game.
As it plays , i want the menu level to be loaded in the background , but only change the level when the video is done playing. I currently have this which does not work.
var introVid:AsyncOperation;
var movieTexture:MovieTexture;
var canLoad:boolean=false;
function Start(){
movieTexture.Play();
LoadLevelAsynchronously();
camera.main.audio.Play();
Debug.Log("level was loaded");
}
function OnGUI () {
GUI.DrawTexture(Rect(0,0,Screen.width,Screen.height),movieTexture,ScaleMode.StretchToFill);
if(!movieTexture.isPlaying)
canLoad=true;
}
function LoadLevelAsynchronously(){
introVid=Application.LoadLevelAsync("Menulvl");
while(!introVid.isDone&&canLoad==false)
yield;
}
What am i doing wrong here?