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.