I'm trying to create a loading bar for loading the next level/scene. I'm following unity3d's scripting manual but i get and error. here is the code:
var loadLevel:boolean = false;
var async:AsyncOperation;
function OnGUI(){
if(GUI.Button(Rect(0,0,100,50),"LoadLevel 1")){
loadLevel = true;
}
}
function Update(){
if(loadLevel){
async = Application.LoadLevelAsync ("Level_01");
yield async;
if(async.isDone){
print ("Loading complete");
}
}
}
The error is: "Script error: Update() can not be a coroutine." when i remove the yield the error is gone but the result is not what i expect. It prints nothing:( ?