• 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
Question by Eco-Editor · Aug 08, 2019 at 03:19 PM · scene-loadingasyncdelegateactioninformation

How to use AsyncOperation.completed?

Hello

I want to use the AsyncOperation.completed delegate but there's not much information about it online, and I'm a bit new to Actions in c#

https://docs.unity3d.com/ScriptReference/AsyncOperation-completed.html

Can somebody explain to me how to implement it in code?

Comment

People who like this

0 Show 2
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 sacredgeometry · Aug 10, 2019 at 11:41 AM 0
Share

Can you give me more context of your implementation please.

avatar image Eco-Editor sacredgeometry · Aug 11, 2019 at 09:58 AM 0
Share

Hello @sacredgeometry My implementation would be to check when the next scene has finished loading and when it has finished, subscribe the next void method. Actually after talking to a friend I understand how it works.

 void Start ()
         {
             var ao = SceneManager.LoadSceneAsync(2);
             ao.completed += O => { LoadingNext(); };
         }
         
     
         void LoadingNext()
         { 
              // *do something*
         }
 
 
     

1 Reply

  • Sort: 
avatar image
Best Answer

Answer by Bieere · Aug 11, 2019 at 04:42 PM

Actions are great, i personally use them a lot for my projects.

when an action is declared Action<AsyncOperation> the type within the angled brackets is the return type of the action. So there are two ways for you to use this.


1. Lambda Operation

 AsyncOperation operation = new AsyncOperation();
 operation.completed += (asyncOperation) =>
 {
     //Do stuff here with returned value asyncOperation
 };



2. Function

 void Test()
 {
     AsyncOperation operation = new AsyncOperation();
     
     operation.completed += OperationOnCompleted;
     
 }
 private void OperationOnCompleted(AsyncOperation obj)
 {
     throw new NotImplementedException();
 }

Comment
Eco-Editor
danilofaugusto
Cakebox

People who like this

3 Show 1 · 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 Eco-Editor · Aug 14, 2019 at 09:05 AM 0
Share

Thanks! the function solution is what I've been looking for.

Unity Answers is in Read-Only mode

Unity Answers content will be migrated to a new Community platform and we are aiming to launch a public beta by June 9. Please note, Unity Answers is now in read-only so we can prepare for the final data migration.

For more information and updates, please read our full announcement thread in the Unity Forum.

Follow this Question

Answers Answers and Comments

114 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

Related Questions

How can I get the last frame before a new level was loaded ? 1 Answer

Loaded 2 async scenes: how to unload or remove 1 of them? 1 Answer

is there any easier way to do this ? 2 Answers

Two async operations at the same time not working ? why ? 0 Answers

Holding SceneManager.LoadSceneAsync until a button has been pressed? 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