• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
Question by ryanmillerca · Oct 20, 2014 at 06:46 PM · loadloadingasyncadditiveload level

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?

Comment
mwbranna
smoggach

People who like this

0 Show 8
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image smoggach · Oct 20, 2014 at 08:02 PM 0
Share

Are you sure you're using it properly? It would help to see how you're using the feature to figure out why it's not working properly in your case.

avatar image ryanmillerca · Oct 20, 2014 at 08:13 PM 0
Share

I'm calling it after a UI object is clicked like this:

 void SomeSortofClick() {
     AsyncOperation async = Application.LoadLevelAdditiveAsync(sceneName);    
     StartCoroutine(LoadLevelCoroutine(async));
 }
 
 IEnumerator LoadLevelCoroutine(AsyncOperation async) {
     Debug.Log("Loading: " + (async.progress*100));
     yield return async;        
 }

avatar image smoggach · Oct 20, 2014 at 08:18 PM 0
Share

Hmm.. It may be because you create the AsyncOperation in a GUI thread.

Try moving your AsyncOperation async = Application.LoadLevelAdditiveAsync(sceneName) into the coroutine.

avatar image ryanmillerca · Oct 20, 2014 at 08:20 PM 0
Share

I'm using NGUI, not the stock UI.

I had AsyncOperation async = Application.LoadLevelAdditiveAsync(sceneName) in the coroutine originally and had the same results.

Did I mention I'm working on iOS? I should have mentioned that.

avatar image smoggach · Oct 20, 2014 at 08:23 PM 0
Share

I'm not sure if it's actually async on iOS. Does it do the same thing when your scene has smaller assets? Perhaps it's just becuase your assets are too big.

Show more comments

3 Replies

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by smoggach · Oct 20, 2014 at 08:31 PM

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

Comment
ryanmillerca

People who like this

1 Show 0 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image

Answer by Bunny83 · Oct 20, 2014 at 08:53 PM

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?

Comment
liortal
ryanmillerca

People who like this

2 Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ryanmillerca · Oct 20, 2014 at 09:12 PM 0
Share

Yep, I have pro. I'll try this; thanks.

avatar image

Answer by liortal · Oct 20, 2014 at 08:54 PM

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

To quote from the documentation here: http://docs.unity3d.com/ScriptReference/Application.LoadLevelAdditiveAsync.html

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.

Comment
ryanmillerca

People who like this

1 Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ryanmillerca · Oct 20, 2014 at 11:34 PM 0
Share

Thanks, I've got Pro and iOS Pro. I think it may simply be that the near 100mb of content I'm loading in some cases is heavy no matter what. I was really hoping for a multithreaded solution and thought that this was it.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

31 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Asyncchronous image loading 2 Answers

Load Level Additive Async Lag spike 0 Answers

SceneManager.LoadSceneAsync freeze loading scene in editor. 0 Answers

Unloading a loaded Scene when load Async for a Loading Bar 1 Answer

LoadLevel takes more time : Unity 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges