- Home /
Asynchronous Level Load Progress on iPhone
Can anyone post some demo code of a working asynchronous level load function? I seem to only get one number or nothing at all when I print the progress to the screen. Then it either sits at that number until it completes or jumps to the next scene without any numbers at all.
BTW I do have the pro version.
Answer by kramcomposer · Mar 04, 2013 at 05:02 AM
Try this class I made for you Just have you GUI read from the progress float. You'll also need to Call loadLevel() when you want to load, and startLevel() when you ready to start the level
public class LoadMe : MonoBehaviour {
public string targetLevel;
public float progress = 0;
private bool _levelIsLoading;
public bool levelIsLoading{
get{ return _levelIsLoading;}
}
private AsyncOperation async;
public void loadLevel(){
_levelIsLoading = true;
async = Application.LoadLevelAsync(targetLevel);
async.allowSceneActivation = false;
}
private void Update(){
if(_levelIsLoading){
progress = async.progress;
}
}
public void startLevel(){
async.allowSceneActivation = true;
}
}
Your answer
Follow this Question
Related Questions
Asyncchronous image loading 2 Answers
Unity Asynchronous Socket Client - Threading Problem 2 Answers
Async/Await function hangs when caller has infinite loop 1 Answer
Unexpected symbol CS1525 2 Answers
Making a forloop wait for previous code to finish before executing without a noticable delay? 0 Answers