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 /
This question was closed Mar 13, 2015 at 06:02 PM by KnightRiderGuy for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by KnightRiderGuy · Mar 12, 2015 at 04:43 PM · unity 5c# tutorialloading screenloadlevelasync

Trouble With Loading Bar Script C# Unity 5

I was following this tutorial on how to make a loading screen on YouTube. I have followed his script exactly but I am getting all sorts of errors and I can't figure out why. YouTube Tutorial

 using UnityEngine;
 using System.Collections;
 
 public class LoadingScreen : MonoBehaviour {
 
     public string levelToLoad;
 
     public GameObject background;
     public GameObject progressBar;
     public GameObject text;
 
     private int loadProgress = 0;
 
     // Use this for initialization
     void Start () {
         background.SetActive (false);
         progressBar.SetActive (false);
         text.SetActive (false);
     }
 
     public void GoMusicPlayer02(){
         StartCoroutine(DisplayLoadingScreen(levelToLoad));
     }
     
     // Update is called once per frame
     void Update () {
         IEnumerator DisplayLoadingScreen(string level){
             background.SetActive (true);
             progressBar.SetActive (true);
             text.SetActive (true);
             
             progressBar.transform.localScale = new Vector3(loadProgress, progressBar.transform.localScale.y, progressBar.transform.z);
             
             text.GetComponent<GUIText>().text = "Loading Progress " + loadProgress + "%";
             
             AsyncOperation async = Application.LoadLevelAsync(level);
             while(!async.isDone){
                 loadProgress = (int)(async.progress * 100);
                 text.GetComponent<GUIText>().text = "Loading Progress " + loadProgress + "%";
                 progressBar.transform.localScale = new Vector3(async.progress, progressBar.transform.localScale.y, progressBar.transform.z);
                 
                 yield return null;
             }
         }
     }
 }


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 KnightRiderGuy · Mar 12, 2015 at 04:44 PM 0
Share

I forgot to include the error messages I am getting:

Assets/Scripts/LoadingScreen.cs(50,1): error CS8025: Parsing error

Assets/Scripts/LoadingScreen.cs(27,49): error CS1525: Unexpected symbol (', expecting )', ,', ;', [', or ='

1 Reply

  • Sort: 
avatar image
0
Best Answer

Answer by m4c0 · Mar 13, 2015 at 02:36 AM

Your IEnumerator DisplayLoadingScreen(string level) is inside void Update(). You can't have a method inside another method.

Comment
Add comment · Show 3 · 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 KnightRiderGuy · Mar 13, 2015 at 05:36 PM 0
Share

Thanks m4c0, Yup that was it, plus the other classic screwup of not having the localScale in front of the z The script works but not as I expected. $$anonymous$$y level that loads still freezes while all of the songs from the array list get loaded in. I thought the whole purpose of the load screen was to prevent that?? Oh well that is another question I suppose ;)

avatar image m4c0 · Mar 13, 2015 at 06:14 PM 0
Share

I can't find in docs, but the guy from the video says it needs Pro license. Could that be it?

avatar image KnightRiderGuy · Mar 13, 2015 at 06:35 PM 0
Share

Yes, unity pro is required but my understanding is that if you have unity 5 you have all of the pro features so that should not matter... unless I'm missing something there?

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

unity LoadSceneAsync works like LoadScene 0 Answers

SceneManager.LoadSceneAsync() problem on Andorid 0 Answers

Character having character controller is very jittery/shaking 4 Answers

Loading screen works perfectly with one scene only and not with others 0 Answers

Got a problem with Async! 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