Prevent LoadLevelAdditiveAsync from halting the app?

I’m loading in fairly big assets additively with Application.LoadLevelAdditiveAsync, and finding it troublesome that the entire application stops updating until the level has completed loading.

The level is loading in a coroutine, and I’ve tried adjusting the priority, but none of this seems to help.

Is there any way to load this additive level while maintaining framerate higher than 0?

Well, could you try this:

IEnumerator LoadLevelCoroutine(AsyncOperation async) {
    Debug.Log("Start Loading: " + (async.progress*100));
    async.allowSceneActivation = false;
    yield return async;
    Debug.Log("Loading Done");
    
    yield return new WaitForSeconds(2); // just for testing
    
    Debug.Log("Activating...");
    async.allowSceneActivation = true;
}

See if the actual lag happens during the loading or the activation of the scene. If it’s during the activation, there’s nothing you can do about that beside making your scene smaller / lighter.

PS: You do have Unity pro and iOS pro, right?

I don’t think it can yet. There are real multi-threading plugins out there though if you really need it.

Your code looks fine - you are using the Unity API as intended.

To quote from the documentation here: Unity - Scripting API: Application.LoadLevelAdditiveAsync

Unity will completely load all assets
and all objects in the scene in a
background loading thread. This allows
you to create a completely streaming
world where you constantly load and
unload different parts of the world
based on the player position, without
any hiccups in game play.

A simple test shows that although Unity loads all assets of the new scene in a background thread (I trust the documentation, i didn’t see that as that thread is probably native), all of your objects’ scripts will execute their Awake() methods before the async loading returns.

This code runs on the main thread, the one where all of your current scene’s objects are running and updating.

So, my logic says that the more objects you have in the loaded scene, and the more complex scripts that are attached to them, the asynchronous loading CAN affect the currently executing scene.

I would perform 2 other tests:

  1. Run the same scenario inside the editor to see what the behaviour is like.
  2. Try to execute the same scenario, with a different scene (smaller one).

P.S: just to verify, using the LoadLevelAdditiveAsync method requires Unity PRO. Without a PRO license i believe it behaves as the regular Load.