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
0
Question by lnutimura · Sep 06, 2015 at 03:14 AM · timelerpwaitforsecondsdelayloading screen

Loading Screen and Lerp

Hello guys,

Recently I've been trying to make a loading screen between some scenes of my game that I'm currently developing, but I've encountered some troubles while trying to do so. I'm using an Enumerator to make the transition between the scenes, and it's working pretty well, I can actually get the progress of the loading. But, it goes too fast, like, once started the loading, it goes from 0 to 19, then 50, 90 and done.

I would like to put some useful informations in the loading screen, so my initial idea was try to Lerp these values, so, if it goes from 0 to 19, I enter a while and show to the player 0, 1, 2, ..., 19, so I can gain more time while loading. I've tried with "yield return new WaitForSeconds (time)" but it didn't work. I've tried to use Mathf.Lerp too, but it keeps loading too fast.

TL;DR: I want to make my loading screen lasts longer than 1 second, maybe doing a Lerp of the values returned from Async.progress, where Async is an instance of AsyncOperation.

Thanks in advance.

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
0

Answer by sath · Sep 06, 2015 at 11:42 AM

@lnutimura a simple way to do this is to load the next level not just after async is done but something else is done too ... (the code below is not tested!!)

     //the async load time
     float percentageLoaded = 0f;
     //start your waiting time
     bool isWaiting = true;
     //time to wait the next scene to load
     float timeToWait = 10f;
     //the timer
     float counter = 0f;
 
     void Start()
     {
         counter = 0f;
         isWaiting = true;
         StartCoroutine (LoadScene());
     }
 
     void Update ()
     {
         //counter
         if(isWaiting)
         {
             //seconds
             counter+= Time.deltaTime;
             //stop condition
             if(counter>= 10f) { isWaiting = false;}
             //here you can show in a text your loading
             Debug.Log("my loading = "+counter);
         }
 
         //load next scene if async is done and your bool is false (isWaiting)
         if (Application.GetStreamProgressForLevel(sceneName) == 1 && !isWaiting) {
             Application.LoadLevel(sceneName);
         }else {
             percentageLoaded = Application.GetStreamProgressForLevel(sceneName);
             Debug.Log("async loading = "+percentageLoaded);
         }
     }
 
     private IEnumerator LoadScene(){
         //Debug.Log ("Loading scene.");
         async = Application.LoadLevelAsync(sceneName);
         //async.allowSceneActivation = false;
         yield return async;
     }
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 lnutimura · Sep 06, 2015 at 07:21 PM

@sath thank you so much for the reply!

I saw your post and I have to tell you that it's very similar to the one that I wrote here after seeing a lot of topics about this theme! So I'm pretty sure that your code will work as well.

Sadly I couldn't make a Lerp between the values returned from the async.progress... I just "locked" the scene with "async.allowSceneActivation" like you did.

However, I'm pretty satisfied with the result but I will keep an eye to create a smooth transition between progress values, instead of holding for the scene for "t" seconds!

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 SheZii · Jan 30, 2019 at 07:52 AM

Detailed Unity3D Actual Loading Screen Tutorial (With free C# Script and Demo project) http://techscenarios.com/2019/01/unity3d-add-loading-screen-to-your-game/

Or watch it on Youtube https://www.youtube.com/watch?v=fx9XjUS1VEQ

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How to delay a function (how to use WaitForSeconds() and yield) 1 Answer

30 Objects all firing at exactly the same time and not randomly 1 Answer

Time Function in Javascript? 1 Answer

Is the delay function in unity faster than WaitForSeconds()? 1 Answer

Waiting for fractions of a Second 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