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
2
Question by TruffelsAndOranges · Sep 29, 2015 at 11:29 AM · asyncasynchronous

Additively loaded scene gets stuck at 90% even if allowSceneActivation is true.

I am basically loading 3-4 scenes at the same time additively and want to activate them simultaneously using another game object. What I get is just my console spammed with:

 "Progress: 0.9, true"

... and none of my scenes are activated. It looks to me as if Unity cant handle multiple async operations. Or am I doing something wrong?

The component which does the loading looks like this (and then I just set "activateScenes" to true from another object):

 public bool activateScenes = false;
 
 public void Start(){
      StartCoroutine(LoadSceneAdd("Scene1"));
      StartCoroutine(LoadSceneAdd("Scene2"));
      StartCoroutine(LoadSceneAdd("Scene3"));
      StartCoroutine(LoadSceneAdd("Scene4"));
 }
 
 private IEnumerator LoadSceneAdd(string name){
      AsyncOperation async = Application.LoadLevelAdditiveAsync(name);
      async.allowSceneActivation = false;
      while(!activateScenes)
      {
               yield return null;
      }
      async.allowSceneActivation = true;
      while(async.progress < 0.999999f)
      {
               Debug.Log("Progress: " + async.progress + ", " + async.allowSceneActivation);
               yield return null;
      }
      Debug.Log("Scene activated!"); // The code never gets here.
      yield break;
 }


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

2 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by Bunny83 · Sep 29, 2015 at 02:34 PM

The async operation represents the whole level loading procedure. IsDone will become true when the loading is "really" finished. That is when the objects of the scene have been activated. That this point where progress will be 1.0 as well.

important:

  • You can load multiple levels but you have to activate them in the same order. So if you load Scene1 followed by Scene2 you can't activate Scene2 until Scene1 has been activated.

  • Make sure you never (ever) load a scene with "allowSceneActivation = false" and never activate it. It will block the loading queue. When you "loose" the reference to the pending AsyncOperation, there's no way to recover it's functionality besides a game restart.

As long as you activate them in the same order that you loaded them it should work just fine. I've made a webplayer example (you need a browser that still supports NPAPI). I've included a link to the only script involved at the bottom of the webplayer page. It's located in the "loader" scene.

When you press the "Load" button it requests Scene1 to Scene4 but sets "allowSceneActivation" to false. Try activating them manually from the bottom to the top. No scene will be activated until the first loaded scene is activated.

As you can see i "disabled" the delete button to ensure you can only remove a level load task from the list when it has been activated.

(ps: I tried building for WebGL but (it feels like) it takes 20x the build time and the final product doesn't seem to run in my FireFox. So i stick to the webplayer ^^).

pps: I currently use Unity 5.1.1f1.

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 Fattie · Feb 23, 2016 at 01:37 PM 0
Share

would you agree it is simply not possible to use allowSceneActivation with LoadSceneAsync ??

You'd think this pattern would work perfectly:

     Debug.Log("about to load!");
     AsyncOperation a;
     a = LoadSceneAsync("HugeScene");
     a.allowSceneActivation = false;
     while (!a.isDone)
         {
         Debug.Log("loading " +a.progress.ToString("n2"));
         yield return null;
         }
     Debug.Log("loaded!!");
     a.allowSceneActivation = true;

but it simply does not.

It can't be that hard to

  • begin loading

  • wait until it's all loaded

  • then activate it

Strange stuff. Is the idea that you in fact must use additive, and then manually UnloadScene of he one you were just in?

(Note I talk only of simply loading one new scene: not multiple scenes as addressed in your A.)

avatar image
0

Answer by Kyle_WG · Sep 29, 2015 at 12:52 PM

Yeah it never fully reaches 1. (Usually 0.9f) Check the flag async.isDone instead. If you're reporting to the user too just use multiply by 100 and use the Mathf.Ceil. You'll get a nice percentage.

Comment
Add comment · Show 8 · 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 TruffelsAndOranges · Sep 29, 2015 at 12:54 PM 0
Share

That's not the problem though, the problem is that the scene never activates. How do I activate the scene?

avatar image Kyle_WG TruffelsAndOranges · Sep 29, 2015 at 01:07 PM 0
Share

Hmmm.. I do it with LoadLevelAsync (setting sync.allowSceneActivation = true;). Change to non-additive for now to see if it works. If it works then it's Unity's LoadLevelAdditiveAsync's problem. What Unity version are you working with? Apparently 5.2 has fixed some of these problems as they're aware of it.

Also try removing all the lines that set async.allowSceneActivation; to see if that bypasses the error.

avatar image TruffelsAndOranges Kyle_WG · Sep 29, 2015 at 01:15 PM 0
Share

I'm using 5.2. async.allowSceneActivation set to true initially bypasses the error, but that means I cannot decide when to activate the scenes myself. The error only happens second time I try to load the scenes (after having all of them unloaded).

Show more comments

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

29 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

Related Questions

LoadLevel Async 2 Answers

How to load scene when async.progress is 0.9? 0 Answers

Odd behaviour when preloading multiple scenes 1 Answer

How to make functions async? 2 Answers

Two async operations at the same time not working ? why ? 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