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 necipcik · Jan 31, 2014 at 12:58 PM · sceneloadbarimage loader

"loading image or a bar" in between scene switching

Hello folks;

i searched the answers and the forums but i could not find what i am looking for so here is my question:

i have a scene which contains multiple buttons that upon clicking take me to other scenes. everything works fine but the other scenes are a little heavy while they are loading. so i need a image or a progress bar while the new scene is loading. in the answers i see lots of people refering to "Application.LoadLevelAsync", but i could not figure out how to do that. so if you please help me about where to put "Application.LoadLevelAsync" code and displaying the image or bar while loading... Here is my code in javascript:

 function OnGUI() {
     
         
      if(GUI.Button(Rect(450, 160, 220, 20), "scene1")) {
     Application.LoadLevel("scene1");
     }
     if(GUI.Button(Rect(450, 185, 220, 20), "scene2")) {
     Application.LoadLevel("scene2");
     }
      if(GUI.Button(Rect(450, 210, 220, 20), "scene3")) {
     Application.LoadLevel("scene3");
     }
     if(GUI.Button(Rect(450, 235, 220, 20), "scene4")) {
     Application.LoadLevel("scene4");
     }
 }

Thank you in advance

Comment
Add comment · Show 1
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 ChankyGames · Jan 18, 2015 at 12:22 AM 0
Share

Incrementally load your scenes in Unity3D (free) with loading bar! Using Unity 4.6 new GUI system or OnGUI! (will also work with NGUI)

https://www.assetstore.unity3d.com/en/#!/content/28035

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by TonyLi · Jan 31, 2014 at 02:31 PM

The LoadLevelAsync and LoadLevelAdditiveAsync functions require Unity Pro.

If you don't have Unity Pro, you'll have to use LoadLevel, which pauses until the level is done. It doesn't provide a way to have a progress bar. You could, however, put a static image on the screen, such as "Loading. Please wait..." while it's loading.

If you have Unity Pro, you'll probably want to run LoadLevelAsync in a coroutine so you can monitor the status of the AsyncOperation returned by LoadLevelAsync. Keep looping in the coroutine until AsyncOperation.isDone is true. Inside the coroutine loop, you can set the value of the progress bar using AsyncOperation.progress. Note that progress doesn't update very accurately when playing inside the editor, but it's much more accurate in end-user builds.

Comment
Add comment · Show 4 · 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 necipcik · Jan 31, 2014 at 03:15 PM 0
Share

i forgot to mention that i have pro. the thing is i do not have the coding skills to add LoadLevelAsync to the code i have above. thats why i kindly ask your help :)

but i will look into the coroutine thingy... thank you again

avatar image TonyLi · Jan 31, 2014 at 04:16 PM 0
Share

unityAnswers isn't a free code-writing service. If you post on the Scripting forum you might get some help writing the code since this will probably require some back-and-forth discussion. Or you could offer to pay someone to do it on the Job Offering forum or buy a product on the Asset Store that does this for you, such as Scene $$anonymous$$anager or $$anonymous$$ad Level $$anonymous$$anager.

avatar image necipcik · Jan 31, 2014 at 05:24 PM 0
Share

by the way, i think i got the solution. Could you be so kind to check it? var ao : AsyncOperation;

 function OnGUI () {
     if(GUI.Button(new Rect(Screen.width / 2 - 100, Screen.height / 2 - 15, 200, 30), "Load Demo")){
             ao = Application.LoadLevelAsync("Demo");
             }
     if(ao != null) {
         GUI.Box (new Rect(0, 40, ao.progress * Screen.width, 40), "Loading");
             }
                 }
avatar image TonyLi · Jan 31, 2014 at 06:05 PM 0
Share

Can't you just test it and see if it works? Anyway, this might work a little better:

 var ao : AsyncOperation;
 
 function OnGUI () {
     var rect = new Rect(Screen.width / 2 - 100, Screen.height / 2 - 15, 200, 30);
     if (GUI.Button(rect, "Load Demo")){
         ao = Application.LoadLevelAsync("Demo");
     }
     if (ao != null) {
         if (ao.IsDone) {
             ao = null;
         } else {
             GUI.Box (new Rect(0, 40, ao.progress * Screen.width, 40), "Loading");
         }
     }
 }
avatar image
0

Answer by poncho · Jan 31, 2014 at 03:09 PM

You could Use LoadLevel, But, load each of your gameobjects by yourself, and implement a loading bar with those elements If you know how many elements you are going to load, then you have your max value, then for every element to load, use a Load.Asset, after it gets loaded and added to the scene, the counter of the bar add 1, and to know the width of your progress bar is barCount/barMaxCount, do not know if thats the optimal, but it is how i use a loading screen in unity free

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

21 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

Related Questions

Load Custom Scene 2 Answers

Anyway to save which seen the player was on, then load that scene back from another one at a different time? 2 Answers

Load Scene by audio clip 2 Answers

How to see what level is running? 2 Answers

How do I open a PC project/scene on MAC? 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