- Home /
LoadLevelAdditiveAsync progress is always 0
I am trying to load an additive scene using 'LoadLevelAdditiveAsync' and the loading of the scene does not progress at all.
Here is the code :
var sceneToLoad :String;
var asyncEOL : AsyncOperation;
var endLoaded:boolean;
function Start () {
endLoaded=false;
}
function Update () {
if(endLoaded==false){
loadLevel();
endLoaded=true;
}
}
function loadLevel () {
if( sceneToLoad!=""){
asyncEOL = Application.LoadLevelAdditiveAsync(sceneToLoad);
while (!asyncEOL.isDone) {
Debug.Log(asyncEOL.progress); // this always outputs 0 and scene never gets loaded.
yield;
}
}
}
PS : There is another scene in the background loaded asynchronously which has not been activated yet.
async = Application.LoadLevelAsync(Application.loadedLevel+1);
async.allowSceneActivation = false;
Async APIs are pro only. Do you have pro? Also, is the level you're trying to load in your BuildSettings? If not it won't load but you should see an error in the console.
Thanks for taking time. Yes, I have unity Pro (in trial period) . Yes, the scene I am loading is in the build settings.
I believe it has something to do with the scene being loaded asynchronously in the background because when I disable async = Application.LoadLevelAsync(Application.loadedLevel+1); async.allowSceneActivation = false;
the scene loads fine
I'm not sure how Unity handles multiple simultaneous async loads. The documentation on AsyncOperation.priority seems to suggest that it might wait for one to finish before starting the next one.
Yeh that sounds about right rutter. Priority only queues before they are processed from what i gather.
Answer by chayanvinayak · Feb 20, 2014 at 02:37 AM
I believe it has something to do with the scene being loaded asynchronously in the background because when I disable async = Application.LoadLevelAsync(Application.loadedLevel+1); async.allowSceneActivation = false;
the scene loads fine.
Answer by mattyman174 · Feb 20, 2014 at 02:22 AM
Try changing your Yield Statement to the Following.
yield asyncEOL;
Try changing the following function as such.
function loadLevel ()
{
if( sceneToLoad!= "")
{
asyncEOL = Application.LoadLevelAdditiveAsync(sceneToLoad);
yield asyncEOL;
}
}
Your answer
Follow this Question
Related Questions
Loaded two scenes asynchronously, neither will activate? 1 Answer
Additive scenes with scene-specific global light settings 0 Answers
Loading scene with LoadSceneAsync freezes and progress jumps from 0% to 90% 2 Answers
SceneManager onActiveSceneChange Pause for a while before loading a new scene 0 Answers