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 The_Three_Vs · Aug 19, 2020 at 09:58 PM · loadingloadlevelasync

Stop AsyncOperation Load

I have a scene that acts as a loading screen of sorts for my main scene. alt text

When this scene loads, I start an AsyncOperation to load the main scene. The "PLAY" button acts as an indicator of main scene's loading progress. When the main scene's loading progress reaches 0.9, the button activates, and pressing the button will load the remaining 0.1 progress and change to the main scene.

The other buttons load and change to other scenes when pressed. However, these scenes, also using AsyncOperation to load, do not start loading, being held up by the main scene's AsyncOperation. Is there any way to stop the main scene's AsyncOperation so that the other scenes can load?

For reference, my code is:

The Play button:

     private void Start()
     {
         m_button.enabled = false;
         m_slider.value = 0f;
 
         StartCoroutine(LoadMainScene());
     }
 
     public void ActivateMainScene()
     {
         if (!GlobalTracker.Instance.SceneLoading)
         {
             m_canGoToMainScene = true;
         }
     }
 
     private IEnumerator LoadMainScene()
     {
         //Start an asynchronous operation to load the main game scene
         AsyncOperation async = SceneManager.LoadSceneAsync(m_mainGameBuildIndex);
         async.allowSceneActivation = false;
 
         //While the asynchronous operation to load the new scene is not yet complete, continue 
         //waiting until it's done.
         while (!async.isDone)
         {
             //If another scene starts loading...
             if(GlobalTracker.Instance.SceneLoading)
             {
                 //Stop loading the main scene
             }
             m_slider.value = async.progress * (10f / 9f);
 
             if (async.progress >= 0.9f)
             {
                 m_button.enabled = true;
 
                 m_slider.value = 1f;
                 //Boolean activated by OnClick
                 if (m_canGoToMainScene)
                 {
                     async.allowSceneActivation = true;
                 }
             }
 
             yield return null;
         }
     }



The other buttons:

     //Triggered by OnClick
     //Activate the Load coroutine with the provided BuildIndex and activate the loading GameObject
     public void LoadScene(int scene)
     {
         if (!ier_Load && !GlobalTracker.Instance.SceneLoading)
         {
             StartCoroutine(Load(scene));
             m_loadingSymbol.SetActive(true);
         }
     }
     private bool ier_Load = false; //Whether there is currently a scene loading
     //Load the scene with the provided BuildIndex
     private IEnumerator Load(int scene)
     {
         ier_Load = true;
         GlobalTracker.Instance.SceneLoading = true;
         //Start an asynchronous operation to load the scene that was passed to the LoadNewScene 
         //coroutine.
         AsyncOperation async = SceneManager.LoadSceneAsync(scene);
 
         //While the asynchronous operation to load the new scene is not yet complete, continue 
         //waiting until it's done.
         while (!async.isDone)
         {
             print(async.progress);
             yield return null;
         }
 
         ier_Load = false;
     }
startbuttons.png (3.4 kB)
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

0 Replies

· Add your reply
  • Sort: 

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

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

Title Screen loading animation not looped 1 Answer

Load music only when everything is loaded 1 Answer

LoadLevelAsync is acting like LoadLevel 5 Answers

LoadLevelAsync slower in a certain computer 0 Answers

Loading screen with LoadLevelAsync 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