• 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 Bizio · Mar 01, 2019 at 03:49 PM · scene-loadingasyncscene loadasynchronousprogress bar

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

I've setup some async scene loading with LoadSceneAsync method to play around with it but apparently it doesn't do anyt$$anonymous$$ng 'asynchronous'. I copy pasted code from official Unity page so there's no mistake on my part. Here's the code

     public IEnumerator LoadScene(Level _level)
     {
         AsyncOperation asyncOperation = SceneManager.LoadSceneAsync(GetSceneName(_level), LoadSceneMode.Single);
         asyncOperation.allowSceneActivation = false;
         Debug.Log("Loading progress: " + asyncOperation.progress);//should get 0 here, right?
 
         w$$anonymous$$le (!asyncOperation.isDone)
         {
             Debug.Log("Loading progress: " + (asyncOperation.progress * 100) + "%");
 
             if (asyncOperation.progress >= 0.9f)
             {
                 Debug.Log("Press the space bar to continue");
 
                 if (Input.GetKeyDown(KeyCode.Space))
                     asyncOperation.allowSceneActivation = true;
             }
 
             yield return null;
         }
     }

You would imagine to get at least few frames of update w$$anonymous$$le the scene loads, so you could update progress bar or somet$$anonymous$$ng but it's doesn't, just straight freeze from 0% to 90% (then it waits for scene activation). Anyone know how to make t$$anonymous$$s w$$anonymous$$le loop run with the scene load?

Comment
IARI
shieldgenerator7

People who like this

2 Show 4
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 asdmidofire · Mar 01, 2019 at 05:01 PM 0
Share

every time i try make a question give me an error!!!!!!

how to change the languages and voices and dialogue from start menu and connect it to all scenes?

my problem is in main menu options languages i want a script that when i choose a language from multi languages system the voices and dialogue and texts change to the language what selected from the menu i wanna a way that's don't make ma game bigger cuz i tried a way that duplicate the game size i tried to do a lot of canvases and in every canvas the language change and alot of game scenes every scene with a voice and dialogue of the chosen language that was hard take long time cuz that i wanna an easy way

avatar image haruna9x asdmidofire · Mar 02, 2019 at 02:06 AM 0
Share

Your question is too general. And it looks like you want us to write all the code for you. And this is not acceptable at Unity answer. What did you try?

avatar image TreyH · Mar 01, 2019 at 06:08 PM 0
Share

What does it print out when you do this?

avatar image Bizio TreyH · Mar 01, 2019 at 06:32 PM 0
Share

https://puu.sh/CTC5N/24ca742fa5.png But after I call SceneManager.LoadSceneAsync It doesn't print out anything because it's frozen for like 3 seconds and then it snaps with all those messages at once.

2 Replies

· Add your reply
  • Sort: 
avatar image

Answer by haruna9x · Mar 01, 2019 at 04:19 PM

Your scene is too small, it must be large enough to be able to see the difference. So you may have to keep the allowSceneActivation parameter to be wrong, then smooth the progress value manually. Most games use the following procedure to load scenes.

  1. Fading the screen to black.

  2. Load "LoadingSene" in Single mode.

  3. Fading the screen to "LoadingScene".

  4. Load new scenes in Single mode, delay the activation of the new scene.

  5. Fading the screen to black.

  6. Activate the new scene.

  7. Fading the screen to a new scene.

Comment
Trifouille

People who like this

1 Show 5 · 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 Bizio · Mar 01, 2019 at 04:57 PM 0
Share

I mean loading my scene takes like 5 seconds and for this time it freezes, I don't think it's a small scene (Maybe it actually is). You are saying that 5 seconds freezes while loading a scene asynchronoustly are normal?

avatar image haruna9x Bizio · Mar 01, 2019 at 05:30 PM 0
Share

The code above is nothing wrong. I want to know how you called it. I think that 5 seconds is enough to load a world as big as Skyrim.

avatar image Bizio haruna9x · Mar 01, 2019 at 05:47 PM 0
Share

I have a GameManager as DontDestroyOnLoad singleton and attached SceneLoader to it. I have transition coroutine that fades screen to black, then I start coroutine that rotates progress arrow in circles and then I load a scene (Arrow doesn't move tho, cuz it's frozen). Then after scene loads I execute method attached to SceneManager.sceneLoaded to remove black screen and that's it. All I want is moving arrow in circles while the scene loads.

Show more comments
avatar image

Answer by Gillissie · Feb 04, 2020 at 08:36 PM

I have to agree with the original post that there is a problem here. Even if the scene is small, the progress shouldn't go like t$$anonymous$$s... (from my logs): 0 (frame 1) 0 (frame 2) 0.1696721 (frame 3) 0.6801639 (frame 4) 0.9 (for 34 frames) Then finally isDone = true. If t$$anonymous$$s was truly asynchronous, whatever Unity is doing during those 34 frames of 0.9 should be spread out more.

My solution is to estimate the load time (by testing), and then manually smooth it out like t$$anonymous$$s:

 var sceneLoader = SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Additive);
 
 float elapsed = 0.0f;
 
 // The amount of time to spread the loading progress over.
 // If the actual time is longer than t$$anonymous$$s, then it will sit at maxSceneLoadProgress until it's actually finished.
 // If shorter, then it will jump to maxSceneLoadProgress when finished.
 // T$$anonymous$$s results in a smoother scene loading progress meter than using sceneLoader.progress, w$$anonymous$$ch jumps quickly to 0.9 then sits on that for a w$$anonymous$$le before actually finis$$anonymous$$ng.
 const float MAX_ELAPSE = 2.0f;
 
 do
 {
     setProgressMeter(Mathf.Clamp01(elapsed / MAX_ELAPSE) * maxSceneLoadProgress);
     yield return null;
     elapsed += Time.deltaTime;
 } w$$anonymous$$le (!sceneLoader.isDone);
 
 setProgressMeter(maxSceneLoadProgress);
 
Comment
Ziplock9000
Tayfe

People who like this

2 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 Ziplock9000 · Dec 06, 2020 at 10:20 PM 0
Share

Wow, this was an issue 4 years ago.. and they still haven't fixed it?

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

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

Capture reference to recently loaded scene asycn 0 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

Odd behaviour when preloading multiple scenes 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