docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Create a custom wait operation

    To create a custom operation, extend the AsyncOperationBase class and override its virtual methods.

    You can pass the derived operation to the ResourceManager.StartOperation method to start the operation and receive an AsyncOperationHandle struct. The ResourceManager registers operations started this way.

    Execute a custom operation

    The ResourceManager invokes the AsyncOperationBase.Execute method for the custom operation once the optional dependent operation completes.

    Completion handling

    When the custom operation completes, call AsyncOperationBase.Complete on the custom operation object. You can call this in the Execute method or defer it to outside the call. AsyncOperationBase.Complete notifies the ResourceManager that the operation has finished. The ResourceManager invokes the associated AsyncOperationHandle.Completed events for the relevant instances of the custom operation.

    Terminate the custom operation

    ResourceManager invokes the AsyncOperationBase.Destroy method for your custom operation when the operation AsyncOperationBase.ReferenceCount reaches zero. AsyncOperationBase.ReferenceCount is decreased when the AsyncOperationHandle that references it is released using Addressables.Release or when AsyncOperationBase.DecrementReferenceCount is called by a custom operation internally. AsyncOperationBase.Destroy is where you should release any memory or resources associated with your custom operation.

    Additional resources

    • AsyncOperationBase API reference
    • Monitor wait operations
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)