Class Addressables | Package Manager UI website
docs.unity3d.com
    Show / Hide Table of Contents

    Class Addressables

    Entry point for Addressable API, this provides a simpler interface than using ResourceManager directly as it assumes string address type.

    Inheritance
    System.Object
    Addressables
    Namespace: UnityEngine.AddressableAssets
    Syntax
    public static class Addressables

    Fields

    kAddressablesRuntimeDataPath

    The name of the PlayerPrefs value used to set the path to load the addressables runtime data file.

    Declaration
    public const string kAddressablesRuntimeDataPath = "AddressablesRuntimeDataPath"
    Field Value
    Type Description
    System.String

    Properties

    BuildPath

    The path used by the Addressables system for its initialization data.

    Declaration
    public static string BuildPath { get; }
    Property Value
    Type Description
    System.String

    InitializationOperation

    Initialization operation. You can register a callback with this if you need to run code after Addressables is ready. Any requests made before this operaton completes will automatically cahin to its result.

    Declaration
    public static AsyncOperationHandle<IResourceLocator> InitializationOperation { get; }
    Property Value
    Type Description
    AsyncOperationHandle<IResourceLocator>

    PlayerBuildDataPath

    The path that addressables player data gets copied to during a player build.

    Declaration
    public static string PlayerBuildDataPath { get; }
    Property Value
    Type Description
    System.String

    ResourceLocators

    Gets the list of configured IResourceLocator objects. Resource Locators are used to find IResourceLocation objects from user-defined typed keys.

    Declaration
    public static IList<IResourceLocator> ResourceLocators { get; }
    Property Value
    Type Description
    System.Collections.Generic.IList<IResourceLocator>

    The resource locators list.

    ResourceManager

    Declaration
    public static ResourceManager ResourceManager { get; }
    Property Value
    Type Description
    ResourceManager

    RuntimePath

    The path used by the Addressables system to load initialization data.

    Declaration
    public static string RuntimePath { get; }
    Property Value
    Type Description
    System.String

    StreamingAssetsSubFolder

    The subfolder used by the Addressables system for its initialization data.

    Declaration
    public static string StreamingAssetsSubFolder { get; }
    Property Value
    Type Description
    System.String

    Methods

    DownloadDependenciesAsync(Object)

    Downloads dependencies of assets marked with the specified label or address.

    Declaration
    public static AsyncOperationHandle DownloadDependenciesAsync(object key)
    Parameters
    Type Name Description
    System.Object key

    The key of the asset(s) to load dependencies for.

    Returns
    Type Description
    AsyncOperationHandle

    The AsyncOperationHandle for the dependency load.

    GetDownloadSizeAsync(Object)

    Determines the required download size, dependencies included, for the specified key. Cached assets require no download and thus their download size will be 0. The Result of the operation is the download size in bytes.

    Declaration
    public static AsyncOperationHandle<long> GetDownloadSizeAsync(object key)
    Parameters
    Type Name Description
    System.Object key

    The key of the asset(s) to get the download size of.

    Returns
    Type Description
    AsyncOperationHandle<System.Int64>

    The operation handle for the request.

    InitializeAsync()

    Initialize Addressables system. Addressables will be initialized on the first API call if this is not called explicitly.

    Declaration
    public static AsyncOperationHandle<IResourceLocator> InitializeAsync()
    Returns
    Type Description
    AsyncOperationHandle<IResourceLocator>

    The operation handle for the request.

    InstantiateAsync(Object, Transform, Boolean, Boolean)

    Instantiate a single object. Note that the dependency loading is done asynchronously, but generally the actual instantiate is synchronous.

    Declaration
    public static AsyncOperationHandle<GameObject> InstantiateAsync(object key, Transform parent = null, bool instantiateInWorldSpace = false, bool trackHandle = true)
    Parameters
    Type Name Description
    System.Object key

    The key of the location of the Object to instantiate.

    Transform parent

    Parent transform for instantiated object.

    System.Boolean instantiateInWorldSpace

    Option to retain world space when instantiated with a parent.

    System.Boolean trackHandle

    If true, Addressables will track this request to allow it to be released via the result object.

    Returns
    Type Description
    AsyncOperationHandle<GameObject>

    The operation handle for the request.

    InstantiateAsync(Object, InstantiationParameters, Boolean)

    Instantiate a single object. Note that the dependency loading is done asynchronously, but generally the actual instantiate is synchronous.

    Declaration
    public static AsyncOperationHandle<GameObject> InstantiateAsync(object key, InstantiationParameters instantiateParameters, bool trackHandle = true)
    Parameters
    Type Name Description
    System.Object key

    The key of the location of the Object to instantiate.

    InstantiationParameters instantiateParameters

    Parameters for instantiation.

    System.Boolean trackHandle

    If true, Addressables will track this request to allow it to be released via the result object.

    Returns
    Type Description
    AsyncOperationHandle<GameObject>

    The operation handle for the request.

    InstantiateAsync(Object, Vector3, Quaternion, Transform, Boolean)

    Instantiate a single object. Note that the dependency loading is done asynchronously, but generally the actual instantiate is synchronous.

    Declaration
    public static AsyncOperationHandle<GameObject> InstantiateAsync(object key, Vector3 position, Quaternion rotation, Transform parent = null, bool trackHandle = true)
    Parameters
    Type Name Description
    System.Object key

    The key of the location of the Object to instantiate.

    Vector3 position

    The position of the instantiated object.

    Quaternion rotation

    The rotation of the instantiated object.

    Transform parent

    Parent transform for instantiated object.

    System.Boolean trackHandle

    If true, Addressables will track this request to allow it to be released via the result object.

    Returns
    Type Description
    AsyncOperationHandle<GameObject>

    The operation handle for the request.

    InstantiateAsync(IResourceLocation, Transform, Boolean, Boolean)

    Instantiate a single object. Note that the dependency loading is done asynchronously, but generally the actual instantiate is synchronous.

    Declaration
    public static AsyncOperationHandle<GameObject> InstantiateAsync(IResourceLocation location, Transform parent = null, bool instantiateInWorldSpace = false, bool trackHandle = true)
    Parameters
    Type Name Description
    IResourceLocation location

    The location of the Object to instantiate.

    Transform parent

    Parent transform for instantiated object.

    System.Boolean instantiateInWorldSpace

    Option to retain world space when instantiated with a parent.

    System.Boolean trackHandle

    If true, Addressables will track this request to allow it to be released via the result object.

    Returns
    Type Description
    AsyncOperationHandle<GameObject>

    The operation handle for the request.

    InstantiateAsync(IResourceLocation, InstantiationParameters, Boolean)

    Instantiate a single object. Note that the dependency loading is done asynchronously, but generally the actual instantiate is synchronous.

    Declaration
    public static AsyncOperationHandle<GameObject> InstantiateAsync(IResourceLocation location, InstantiationParameters instantiateParameters, bool trackHandle = true)
    Parameters
    Type Name Description
    IResourceLocation location

    The location of the Object to instantiate.

    InstantiationParameters instantiateParameters

    Parameters for instantiation.

    System.Boolean trackHandle

    If true, Addressables will track this request to allow it to be released via the result object.

    Returns
    Type Description
    AsyncOperationHandle<GameObject>

    The operation handle for the request.

    InstantiateAsync(IResourceLocation, Vector3, Quaternion, Transform, Boolean)

    Instantiate a single object. Note that the dependency loading is done asynchronously, but generally the actual instantiate is synchronous.

    Declaration
    public static AsyncOperationHandle<GameObject> InstantiateAsync(IResourceLocation location, Vector3 position, Quaternion rotation, Transform parent = null, bool trackHandle = true)
    Parameters
    Type Name Description
    IResourceLocation location

    The location of the Object to instantiate.

    Vector3 position

    The position of the instantiated object.

    Quaternion rotation

    The rotation of the instantiated object.

    Transform parent

    Parent transform for instantiated object.

    System.Boolean trackHandle

    If true, Addressables will track this request to allow it to be released via the result object.

    Returns
    Type Description
    AsyncOperationHandle<GameObject>

    The operation handle for the request.

    LoadAssetAsync<TObject>(Object)

    Load a single asset

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

    The key of the location of the asset.

    Returns
    Type Description
    AsyncOperationHandle<TObject>
    Type Parameters
    Name Description
    TObject

    LoadAssetAsync<TObject>(IResourceLocation)

    Load a single asset

    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>
    Type Parameters
    Name Description
    TObject

    LoadAssetsAsync<TObject>(IList<Object>, Action<TObject>, Addressables.MergeMode)

    Load mutliple assets

    Declaration
    public static AsyncOperationHandle<IList<TObject>> LoadAssetsAsync<TObject>(IList<object> keys, Action<TObject> callback, Addressables.MergeMode mode)
    Parameters
    Type Name Description
    System.Collections.Generic.IList<System.Object> keys

    List of keys for the locations.

    System.Action<TObject> callback

    Callback Action that is called per load operation.

    Addressables.MergeMode mode

    Method for merging the results of key matches. See Addressables.MergeMode for specifics

    Returns
    Type Description
    AsyncOperationHandle<System.Collections.Generic.IList<TObject>>

    The operation handle for the request.

    Type Parameters
    Name Description
    TObject

    LoadAssetsAsync<TObject>(IList<IResourceLocation>, Action<TObject>)

    Load multiple assets

    Declaration
    public static AsyncOperationHandle<IList<TObject>> LoadAssetsAsync<TObject>(IList<IResourceLocation> locations, Action<TObject> callback)
    Parameters
    Type Name Description
    System.Collections.Generic.IList<IResourceLocation> locations

    The locations of the assets.

    System.Action<TObject> callback

    Callback Action that is called per load operation.

    Returns
    Type Description
    AsyncOperationHandle<System.Collections.Generic.IList<TObject>>

    The operation handle for the request.

    Type Parameters
    Name Description
    TObject

    LoadAssetsAsync<TObject>(Object, Action<TObject>)

    Load mutliple assets

    Declaration
    public static AsyncOperationHandle<IList<TObject>> LoadAssetsAsync<TObject>(object key, Action<TObject> callback)
    Parameters
    Type Name Description
    System.Object key

    Key for the locations.

    System.Action<TObject> callback

    Callback Action that is called per load operation.

    Returns
    Type Description
    AsyncOperationHandle<System.Collections.Generic.IList<TObject>>

    The operation handle for the request.

    Type Parameters
    Name Description
    TObject

    LoadContentCatalogAsync(String, String)

    Additively load catalogs from runtime data. The settings are not used.

    Declaration
    public static AsyncOperationHandle<IResourceLocator> LoadContentCatalogAsync(string catalogPath, string providerSuffix = null)
    Parameters
    Type Name Description
    System.String catalogPath

    The path to the runtime data.

    System.String providerSuffix

    This value, if not null or empty, will be appended to all provider ids loaded from this data.

    Returns
    Type Description
    AsyncOperationHandle<IResourceLocator>

    The operation handle for the request.

    LoadResourceLocationsAsync(IList<Object>, Addressables.MergeMode)

    Loads the resource locations specified by the keys.

    Declaration
    public static AsyncOperationHandle<IList<IResourceLocation>> LoadResourceLocationsAsync(IList<object> keys, Addressables.MergeMode mode)
    Parameters
    Type Name Description
    System.Collections.Generic.IList<System.Object> keys

    The set of keys to use.

    Addressables.MergeMode mode

    The mode for merging the results of the found locations.

    Returns
    Type Description
    AsyncOperationHandle<System.Collections.Generic.IList<IResourceLocation>>

    The operation handle for the request.

    LoadResourceLocationsAsync(Object)

    Request the locations for a given key.

    Declaration
    public static AsyncOperationHandle<IList<IResourceLocation>> LoadResourceLocationsAsync(object key)
    Parameters
    Type Name Description
    System.Object key

    The key for the locations.

    Returns
    Type Description
    AsyncOperationHandle<System.Collections.Generic.IList<IResourceLocation>>

    The operation handle for the request.

    LoadSceneAsync(Object, LoadSceneMode, Boolean, Int32)

    Load scene.

    Declaration
    public static AsyncOperationHandle<SceneInstance> LoadSceneAsync(object key, LoadSceneMode loadMode = null, bool activateOnLoad = true, int priority = 100)
    Parameters
    Type Name Description
    System.Object key

    The key of the location of the scene to load.

    LoadSceneMode loadMode

    Scene load mode.

    System.Boolean activateOnLoad

    If false, the scene will load but not activate (for background loading). The SceneInstance returned has an Activate() method that can be called to do this at a later point.

    System.Int32 priority

    Async operation priority for scene loading.

    Returns
    Type Description
    AsyncOperationHandle<SceneInstance>

    The operation handle for the request.

    LoadSceneAsync(IResourceLocation, LoadSceneMode, Boolean, Int32)

    Load scene.

    Declaration
    public static AsyncOperationHandle<SceneInstance> LoadSceneAsync(IResourceLocation location, LoadSceneMode loadMode = null, bool activateOnLoad = true, int priority = 100)
    Parameters
    Type Name Description
    IResourceLocation location

    The location of the scene to load.

    LoadSceneMode loadMode

    Scene load mode.

    System.Boolean activateOnLoad

    If false, the scene will load but not activate (for background loading). The SceneInstance returned has an Activate() method that can be called to do this at a later point.

    System.Int32 priority

    Async operation priority for scene loading.

    Returns
    Type Description
    AsyncOperationHandle<SceneInstance>

    The operation handle for the request.

    Log(String)

    Debug.Log wrapper method that is contional on the LOG_ADDRESSABLES symbol definition. This can be set in the Player preferences in the 'Scripting Define Symbols'.

    Declaration
    [Conditional("ADDRESSABLES_LOG_ALL")]
    public static void Log(string msg)
    Parameters
    Type Name Description
    System.String msg

    The msg to log

    LogError(String)

    Debug.LogError wrapper method.

    Declaration
    public static void LogError(string msg)
    Parameters
    Type Name Description
    System.String msg

    The msg to log

    LogErrorFormat(String, Object[])

    Debug.LogErrorFormat wrapper method.

    Declaration
    public static void LogErrorFormat(string format, params object[] args)
    Parameters
    Type Name Description
    System.String format

    The string with format tags.

    System.Object[] args

    The args used to fill in the format tags.

    LogException(AsyncOperationHandle, Exception)

    Debug.LogException wrapper method.

    Declaration
    public static void LogException(AsyncOperationHandle op, Exception ex)
    Parameters
    Type Name Description
    AsyncOperationHandle op
    System.Exception ex

    LogFormat(String, Object[])

    Debug.LogFormat wrapper method that is contional on the LOG_ADDRESSABLES symbol definition. This can be set in the Player preferences in the 'Scripting Define Symbols'.

    Declaration
    [Conditional("ADDRESSABLES_LOG_ALL")]
    public static void LogFormat(string format, params object[] args)
    Parameters
    Type Name Description
    System.String format

    The string with format tags.

    System.Object[] args

    The args used to fill in the format tags.

    LogWarning(String)

    Debug.LogWarning wrapper method.

    Declaration
    public static void LogWarning(string msg)
    Parameters
    Type Name Description
    System.String msg

    The msg to log

    LogWarningFormat(String, Object[])

    Debug.LogWarningFormat wrapper method.

    Declaration
    public static void LogWarningFormat(string format, params object[] args)
    Parameters
    Type Name Description
    System.String format

    The string with format tags.

    System.Object[] args

    The args used to fill in the format tags.

    Release(AsyncOperationHandle)

    Release the operation and its associated resources.

    Declaration
    public static void Release(AsyncOperationHandle handle)
    Parameters
    Type Name Description
    AsyncOperationHandle handle

    The operation handle to release.

    Release<TObject>(TObject)

    Release asset.

    Declaration
    public static void Release<TObject>(TObject obj)
    Parameters
    Type Name Description
    TObject obj

    The asset to release.

    Type Parameters
    Name Description
    TObject

    The type of the object being released

    Release<TObject>(AsyncOperationHandle<TObject>)

    Release the operation and its associated resources.

    Declaration
    public static void Release<TObject>(AsyncOperationHandle<TObject> handle)
    Parameters
    Type Name Description
    AsyncOperationHandle<TObject> handle

    The operation handle to release.

    Type Parameters
    Name Description
    TObject

    The type of the AsyncOperationHandle being released

    ReleaseInstance(GameObject)

    Releases and destroys an object that was created via Addressables.InstantiateAsync.

    Declaration
    public static void ReleaseInstance(GameObject instance)
    Parameters
    Type Name Description
    GameObject instance

    The GameObject instance to be released and destroyed.

    ReleaseInstance(AsyncOperationHandle)

    Releases and destroys an object that was created via Addressables.InstantiateAsync.

    Declaration
    public static void ReleaseInstance(AsyncOperationHandle handle)
    Parameters
    Type Name Description
    AsyncOperationHandle handle

    The handle to the game object to destroy, that was returned by InstantiateAsync.

    ReleaseInstance(AsyncOperationHandle<GameObject>)

    Releases and destroys an object that was created via Addressables.InstantiateAsync.

    Declaration
    public static void ReleaseInstance(AsyncOperationHandle<GameObject> handle)
    Parameters
    Type Name Description
    AsyncOperationHandle<GameObject> handle

    The handle to the game object to destroy, that was returned by InstantiateAsync.

    ResolveInternalId(String)

    Used to resolve a string using addressables config values

    Declaration
    public static string ResolveInternalId(string id)
    Parameters
    Type Name Description
    System.String id
    Returns
    Type Description
    System.String

    UnloadSceneAsync(AsyncOperationHandle, Boolean)

    Release scene

    Declaration
    public static AsyncOperationHandle<SceneInstance> UnloadSceneAsync(AsyncOperationHandle handle, bool autoReleaseHandle = true)
    Parameters
    Type Name Description
    AsyncOperationHandle handle

    The handle returned by LoadSceneAsync for the scene to release.

    System.Boolean autoReleaseHandle

    If true, the handle will be released automatically when complete.

    Returns
    Type Description
    AsyncOperationHandle<SceneInstance>

    The operation handle for the request.

    UnloadSceneAsync(AsyncOperationHandle<SceneInstance>, Boolean)

    Release scene

    Declaration
    public static AsyncOperationHandle<SceneInstance> UnloadSceneAsync(AsyncOperationHandle<SceneInstance> handle, bool autoReleaseHandle = true)
    Parameters
    Type Name Description
    AsyncOperationHandle<SceneInstance> handle

    The handle returned by LoadSceneAsync for the scene to release.

    System.Boolean autoReleaseHandle

    If true, the handle will be released automatically when complete.

    Returns
    Type Description
    AsyncOperationHandle<SceneInstance>

    The operation handle for the request.

    UnloadSceneAsync(SceneInstance, Boolean)

    Release scene

    Declaration
    public static AsyncOperationHandle<SceneInstance> UnloadSceneAsync(SceneInstance scene, bool autoReleaseHandle = true)
    Parameters
    Type Name Description
    SceneInstance scene

    The SceneInstance to release.

    System.Boolean autoReleaseHandle

    If true, the handle will be released automatically when complete.

    Returns
    Type Description
    AsyncOperationHandle<SceneInstance>

    The operation handle for the request.

    In This Article
    • Fields
      • kAddressablesRuntimeDataPath
    • Properties
      • BuildPath
      • InitializationOperation
      • PlayerBuildDataPath
      • ResourceLocators
      • ResourceManager
      • RuntimePath
      • StreamingAssetsSubFolder
    • Methods
      • DownloadDependenciesAsync(Object)
      • GetDownloadSizeAsync(Object)
      • InitializeAsync()
      • InstantiateAsync(Object, Transform, Boolean, Boolean)
      • InstantiateAsync(Object, InstantiationParameters, Boolean)
      • InstantiateAsync(Object, Vector3, Quaternion, Transform, Boolean)
      • InstantiateAsync(IResourceLocation, Transform, Boolean, Boolean)
      • InstantiateAsync(IResourceLocation, InstantiationParameters, Boolean)
      • InstantiateAsync(IResourceLocation, Vector3, Quaternion, Transform, Boolean)
      • LoadAssetAsync<TObject>(Object)
      • LoadAssetAsync<TObject>(IResourceLocation)
      • LoadAssetsAsync<TObject>(IList<Object>, Action<TObject>, Addressables.MergeMode)
      • LoadAssetsAsync<TObject>(IList<IResourceLocation>, Action<TObject>)
      • LoadAssetsAsync<TObject>(Object, Action<TObject>)
      • LoadContentCatalogAsync(String, String)
      • LoadResourceLocationsAsync(IList<Object>, Addressables.MergeMode)
      • LoadResourceLocationsAsync(Object)
      • LoadSceneAsync(Object, LoadSceneMode, Boolean, Int32)
      • LoadSceneAsync(IResourceLocation, LoadSceneMode, Boolean, Int32)
      • Log(String)
      • LogError(String)
      • LogErrorFormat(String, Object[])
      • LogException(AsyncOperationHandle, Exception)
      • LogFormat(String, Object[])
      • LogWarning(String)
      • LogWarningFormat(String, Object[])
      • Release(AsyncOperationHandle)
      • Release<TObject>(TObject)
      • Release<TObject>(AsyncOperationHandle<TObject>)
      • ReleaseInstance(GameObject)
      • ReleaseInstance(AsyncOperationHandle)
      • ReleaseInstance(AsyncOperationHandle<GameObject>)
      • ResolveInternalId(String)
      • UnloadSceneAsync(AsyncOperationHandle, Boolean)
      • UnloadSceneAsync(AsyncOperationHandle<SceneInstance>, Boolean)
      • UnloadSceneAsync(SceneInstance, Boolean)
    Back to top
    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