• 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 /
  • Help Room /
avatar image
1
Question by koopatroopas · Feb 23, 2016 at 11:19 AM · unity 5

Unity 5.3, unclear API of SceneManager.LoadSceneAsync() and SceneManager.SetActiveScene()

I try to understand the "multiscene" feature of unity 5.3. My goal is to have 2 loaded scenes and only one of them will be active.

I have the Following Script to load the second scene async in background and do not set as active scene after finishing loading.

         IEnumerator LoadGameScene()
         {
             Debug.Log ( "START Load Async" );
             var result = SceneManager.LoadSceneAsync ( "Game", LoadSceneMode.Additive );
             result.allowSceneActivation = false;
 
             while (!result.isDone) 
             {
                 Debug.Log ( "progress: " + result.progress );
                 yield return new WaitForEndOfFrame ();
             }
             Debug.Log ( "YEAH Loaded Async" );
             // still scene one should be active, tryed it as workaround, did not help
             SceneManager.SetActiveScene (SceneManager.GetSceneByName ("Main"));
         }

what happens here is that progress is allways 0.9 and isDone is never getting true. if i change result.allowSceneActivation to true, it works but both scene are active.

i dont get it.

maybe someone can help or could explain how i achieve my goal ;)

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

3 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by Fattie · Feb 23, 2016 at 01:40 PM

It's just another screw-up by Unity

Note my comment ... http://answers.unity3d.com/answers/1073667/view.html

Comment
Add comment · 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 koopatroopas · Feb 23, 2016 at 03:23 PM 0
Share

Seems that i am not the only one who do not understand the API :) maybe it is just a bug. but unfortunately i did not find any issue to that topic. I think i will report it.

avatar image
2

Answer by Andy Lee · May 25, 2016 at 02:57 AM

Seems both of you have been confused by "allowSceneActivation". I agree that Unity's documentation can be done better. But to be fair, "allowSceneActivation" was introduced in Unity 4, way before multi-scene was a thing. It has nothing to do with such feature. It is used for loading a scene asynchronously without having it immediately opened when loading is completed.

E.g. load the main scene asynchronously while splash animation is played. Typically you don't want the splash animation being cut when loading is completed. Therefore, "allowSceneActivation" is useful in this case. Set it to false before animation ends, and to true after that.

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
avatar image
0

Answer by Decabus · Jan 23, 2017 at 04:33 PM

Alright, this is actually covered by the API. Basically, you can't uncheck for allowing scene activation before loading, and then check for isDone to load - because allowSceneActivation actually counts towards whether it's done or not. So it you don't allow it, it'll never be done. Alternatively, you could check if progress is at 0.9, THEN allow it, THEN load.

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.

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

66 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

Related Questions

KeyNotFoundException: Morph3d 1 Answer

What is microsoft visual studio and what does it do exactly ? 1 Answer

Pose of Gameobject cannot be set in World coordinates 0 Answers

Unhandled Exception: System.StackOverflowException when using Switch Statement? 1 Answer

Playing a sprite animation before an object is destroyed 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