• 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 cdnDave · Jun 15, 2016 at 06:21 AM · scene-loadingasyncasynchronous

Odd behaviour when preloading multiple scenes

I've been playing around with the SceneManager to see how flexible the async scene loading is and have quickly run into some strange behaviour. The first thing I tried out was loading two scenes asynchronously and then activating one or the other or both. I'm using version 5.3.4f1.

 public class RootSceneController : MonoBehaviour {
 
     Dictionary<string, AsyncOperation> preloadingScenes;
 
     void Start () {
         preloadingScenes = new Dictionary<string, AsyncOperation>();
    
         PreLoadScene("A");
         PreLoadScene("B");

         //In this case I'm setting both to activate which works as expected
         //Things get weird when  the second loaded screen is allowed to activate but not the first 

         preloadingScenes["A"].allowSceneActivation = true;
         preloadingScenes["B"].allowSceneActivation = true;
         
     }
 
     void Update () {
         print(preloadingScenes["A"].progress);
         print(preloadingScenes["B"].progress); 
   }
 
     public void PreLoadScene(string sceneName)
     {
         if (!preloadingScenes.ContainsKey(sceneName))
         {
             AsyncOperation async = SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Additive);
             async.allowSceneActivation = false;
             preloadingScenes.Add(sceneName, async);
         }
     }
 }
 

When I set 'allowSceneActivation = true' on both scenes everything works as expected, both scenes are additively loaded and activated.

Setting 'allowSceneActivation = true' on scene A but not scene B also works as expected, scene A is loaded and activated while scene B is loaded and it's progress value remains at 0.9 (the expected value for a scene that's loaded but not activated).

However, when I set 'allowSceneActivation = true' on scene B but not scene A things get weird. Both scenes load until their progress values are at 0.9 but scene B never activates.

I have tried flipping the orders of the PreloadScene() calls and it seems consistent in that you if you preload two scenes you can't activate the second loaded scene without having already activated the first.

Does anyone know if this is the expected behaviour or if it might be a bug? I'd like to preload scenes representing areas immediately around the characters current area without knowing which one they might enter, from what I can tell this will prevent me from being able to do that.

Comment

People who like this

0 Show 0
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

1 Reply

· Add your reply
  • Sort: 
avatar image

Answer by WillTM · Jun 17, 2016 at 04:05 PM

I'm pretty sure that is expected behavior, run a search for 'async loading stuck at 0.9 ( 90%)' or something similar, I think i've read setting allowSceneActivation = false will stall the load process completely ( for other scene loads aswell) until the stalled scene has been allowed to finish loading i.e had allowSceneActivation = true , and finished that last bit. then it will continue with the second load operation.

Comment

People who like this

0 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

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Loading scene with LoadSceneAsync freezes and progress jumps from 0% to 90% 2 Answers

AsyncOperation activating immediately even with async.allowSceneActivation = false; 0 Answers

Two async operations at the same time not working ? why ? 0 Answers

Can't access AsyncOperation instance to change allowSceneActivation 2 Answers

SceneManager.LoadScene used within promise (or async callback) does nothing 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