Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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
0
Question by BigScary · Apr 30, 2018 at 09:17 PM · scene-loadingasynchronous

Loaded two scenes asynchronously, neither will activate?

After I do this:

 this.operation = SceneManager.LoadSceneAsync("Scene_A");
 this.operation.allowSceneActivation = false;
 this.operation = SceneManager.LoadSceneAsync("Scene_B");
 this.operation.allowSceneActivation = false;
 yield return new WaitForSeconds(5f);
 this.operation.allowSceneActivation = true;

I expect Scene_B to load when it's ready. However that scene does NOT activate. There are no errors in the console and the currently-loaded scene stays loaded. It's as if no code ran at all (I debugged through it and confirmed that all lines execute). I've also confirmed that Scene_B loads fine when loaded synchronously.

What am I doing wrong, here? Is pre-loading two scenes and then later deciding which to activate not supported?

Comment
Add comment
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
0

Answer by IgorAherne · May 01, 2018 at 04:04 AM

yes, you can file a bug report to Unity. I did and they said "Not enough inscentive to re-program our system" to allow for such an instant activation. Also, Monobehavior.Start is not conforming to execution order, regardless of the order in which you activate your scenes, unless you do it like me in the code below:


My code suffices like so:

 using System.Linq;
 
 private  List<AsyncOperation> _loadingOperations = new List<AsyncOperation>();


 IEnumerator LoadUp_ThisCrap(List<string> sceneNames){
   
       foreach(string sceneName in sceneNames) {
             AsyncOperation oper = SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Additive);
             oper.allowSceneActivation = false;//scenes will be activated after all loaded.
             _loadingOperations.Add(oper);
       }//end foreach
 
       while (true){
             float progress_01 =  _loadingOperations.Average(oper=>oper.progress);
             if(progressFunction != null) {  progressFunction(progress_01 / 0.9f);  }//issue callbacks to anyone interested
             if(progress_01 > 0.9f){ break; }
             yield return null;
       }//end while
 
       //all scenes loaded, now activate them in the order they were supplied:
         for(int i=0; i< _loadingOperations.Count; ++i) {
             AsyncOperation oper = _loadingOperations[i];
             oper.allowSceneActivation = true;
             yield return oper;//<-- wait for it to complete, because unity will screw up activation order
         }
 }


Comment
Add comment · 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.

Follow this Question

Answers Answers and Comments

83 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 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 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

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

WebGL missing function pthread_create? 1 Answer

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

How to call NetworkClient.Ready() ? 1 Answer


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