Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 saldavonschwartz · Jun 24, 2015 at 05:07 AM · unity 5loadlevelasync

allowSceneActivation only works once in the editor when trying to delay loading a scene.

I'm trying to delay reloading a level until after I'm done showing some animation. My code is basically:

 IEnumerator killPlayer(GameObject player) {
     AsyncOperation reload = Application.LoadLevelAsync(Application.loadedLevel);
     reload.allowSceneActivation = false;
     
     while (**<some condition>**) {          
       // Show the player dying, some animation, etc
       yield return null;
     }
     
     while (reload.progress < 0.9f) {
       yield return null;
     }
     
     reload.allowSceneActivation = true;
   }

As you can see, the key thing is the setting of allowSceneActivation to false so that even if the scene is done loading, it won't kill the current scene until eat least after my other animations are done (the first while loop). By the time the first loop is done, the next one potentially waits until we reached the infamous undocumented 90% and only then do I re-enable allowSceneActivation to finally load the scene.

When I try this in the editor, the first time around it works just fine. But after working once, it never again reloads the scene, because the second while never breaks, because the progress is stuck at 0.

Any thoughts?

Comment
Add comment · Show 3
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 zach-r-d · Jun 24, 2015 at 07:56 AM 0
Share

Why not remove the second while loop? What's preventing reallowing scene activation as soon as the desired condition is fulfilled?

FWIW, progress being stuck at 0 in the editor seems to be a known bug.

avatar image saldavonschwartz · Jun 24, 2015 at 08:23 AM 0
Share

interestingly, I take out the while and it works. So I guess I'll leave it out. The reason why I had the while was cause even at 90% loaded, if I allowed the scene to load I could still tell there was a bit of overhead. But whatever, at least it works. And thanks for the tip on the editor bug.

avatar image TrollAxeThrower · Feb 18, 2016 at 11:05 AM 0
Share

@saldavonschwartz Have you found a solution to this?

0 Replies

· Add your reply
  • Sort: 

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

23 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

Related Questions

Got a problem with Async! 0 Answers

LoadLevelAsync multiple pending scenes? 0 Answers

unity LoadSceneAsync works like LoadScene 0 Answers

Trouble With Loading Bar Script C# Unity 5 1 Answer

LoadLevelAsync never executes on a background thread? 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