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 Benajben · Apr 14, 2014 at 09:46 PM · loading fileload asset

LoadLevelAsync Wait to load (C#)

Hello, I'm trying to load a level using a loading screen and so far I've got a bit of it working. However I'd like the user to have to press a key before continuing to the actual level. This is what I have so far and in my mind it should work, but obviously its not :/

 IEnumerator LoadLevel()
     {
         AsyncOperation async = Application.LoadLevelAsync(levelName);
 
         while(!async.isDone)//This hits 90% and then loads level automatically
         {
             percent.text = (async.progress * 100).ToString("F0") + "%";
             yield return new WaitForEndOfFrame();
         }
 
         while(async.isDone)//This isn't working
         {
             percent.text = "Press Any Key to Continue";
 
             if(Input.anyKeyDown)
                 yield return async;
         }
     }
Comment
Add comment · Show 6
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 Benajben · Apr 14, 2014 at 10:44 PM 0
Share

ok I've discovered AsyncOperation.allowSceneActivation, and set that to false. But the issue I'm having now is that while(async.isdone) is never triggering.

avatar image Benajben · Apr 14, 2014 at 10:49 PM 0
Share

it seems async.isDone is ALWAYS false

avatar image nyonge · May 02, 2014 at 12:49 AM 0
Share

Bump! I'm having the exact same problem! As far as I can tell it's a fundamental bug with Unity itself. Has anyone else experienced this?

avatar image jamiltron nyonge · May 02, 2014 at 12:56 AM 0
Share

This isn't an answer.

avatar image Benajben nyonge · May 03, 2014 at 02:34 AM 0
Share

I discovered through some research that it stops at .9f (magic number). So just check for that in your code.

avatar image TreyH · Mar 21, 2019 at 02:30 PM 0
Share

90% is the maximum it can load in the background iirc, the rest involves actual scene manipulation. You can check for when the load is near 0.9f and then finish after that.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by $$anonymous$$ · Mar 21, 2019 at 12:49 PM

https://docs.unity3d.com/ja/current/ScriptReference/AsyncOperation-allowSceneActivation.html The answer is here. Shortly, async.progress always keeps <= 0.9f so async.isDone is always FALSE.

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

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

how do I load a 3d model on the fly 0 Answers

How do you run a exe from code 1 Answer

Can't open file when loading from WWW stream 2 Answers

Share creations with friends 0 Answers

How to Save and Load a list of Scriptable Objects from a File? 2 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