docs.unity3d.com
    Show / Hide Table of Contents

    Method LoadAssetAsync

    LoadAssetAsync<TObject>(IResourceLocation)

    Loads a single Addressable asset identified by an IResourceLocation.

    Declaration
    public static AsyncOperationHandle<TObject> LoadAssetAsync<TObject>(IResourceLocation location)
    Parameters
    Type Name Description
    IResourceLocation location

    The location of the asset.

    Returns
    Type Description
    AsyncOperationHandle<TObject>

    Returns the load operation.

    Type Parameters
    Name Description
    TObject

    The type of the asset.

    Remarks

    When you load an Addressable asset, the system:

    • Gathers the asset's dependencies
    • Downloads any remote AssetBundles needed to load the asset or its dependencies
    • Loads the AssetBundles into memory
    • Populates the Result object of the AsyncOperationHandle<TObject> instance returned by this function.

    Use the Result object to access the loaded assets.

    See Loading Addressable Assets for more information and examples.

    See Operations for information on handling the asynchronous operations used to load Addressable assets.

    LoadAssetAsync<TObject>(Object)

    Loads a single Addressable asset identified by a key such as an address or label.

    Declaration
    public static AsyncOperationHandle<TObject> LoadAssetAsync<TObject>(object key)
    Parameters
    Type Name Description
    Object key

    The key of the location of the asset.

    Returns
    Type Description
    AsyncOperationHandle<TObject>

    Returns the load operation.

    Type Parameters
    Name Description
    TObject

    The type of the asset.

    Remarks

    When you load an Addressable asset, the system:

    • Gathers the asset's dependencies
    • Downloads any remote AssetBundles needed to load the asset or its dependencies
    • Loads the AssetBundles into memory
    • Populates the Result object of the AsyncOperationHandle<TObject> instance returned by this function.

    Use the Result object to access the loaded assets.

    Note that if you provide a key, such as a label, that maps to more than one asset, only the first object encountered by the loading operation is returned. Use LoadAssetsAsync<TObject>(Object, Action<TObject>) or one of its overloads to load multiple assets in a single operation.

    See Loading Addressable Assets for more information and examples.

    See Operations for information on handling the asynchronous operations used to load Addressable assets.

    In This Article
    • LoadAssetAsync<TObject>(IResourceLocation)
    • LoadAssetAsync<TObject>(Object)
    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie 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.
    Generated by DocFX on 18 October 2023