Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 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
Add comment · 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 $$anonymous$$y 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 = Scene$$anonymous$$anager.LoadSceneAsync(2);
             ao.completed += O => { LoadingNext(); };
         }
         
     
         void LoadingNext()
         { 
              // *do something*
         }
 
 
     

1 Reply

· Add your reply
  • Sort: 
avatar image
3
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
Add comment · 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.

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

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 to implement a loading screen for a procedurally-generated level? 1 Answer

How to get references when load a new scene? 0 Answers

How to make a list of Actions or methods? 1 Answer

Capture reference to recently loaded scene asycn 0 Answers

Loading scene with LoadSceneAsync freezes and progress jumps from 0% to 90% 2 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