IAsyncAssetProvider
An optional capability for an asset provider that loads assets asynchronously.
Read time 1 minuteLast updated 12 days ago
Definition
- Type: Interface
- Namespace: Unity.Localization.Providers
- Assembly: UnityEngine.LocalizationRuntimeModule
public interface IAsyncAssetProvider : IAssetProvider
Remarks
Implement this alongside IAssetProvider when a provider loads through an asynchronous operation, such as a Resources request or Addressables. The localization system calls this on the asynchronous resolve paths. A provider that can also resolve immediately implements ISynchronousAssetProvider as well; one that can only resolve immediately implements just the synchronous capability, and the asynchronous paths wrap its result in a completed Awaitable.
Additional Resources: IAssetProvider, ISynchronousAssetProvider
A provider that resolves its assets through an asynchronous operation.
Examples
using System.Threading;using Unity.Localization.Providers;using UnityEngine;using Object = UnityEngine.Object;namespace Unity.Localization.Samples{ public class IAsyncAssetProviderExample : IAsyncAssetProvider { public async Awaitable<T> LoadAssetAsync<T>(AssetKey key, CancellationToken cancellationToken) where T : Object { await Awaitable.NextFrameAsync(cancellationToken); return null; } public void Release(Object asset) { } }}
Methods
Method | Description |
|---|---|
| LoadAssetAsync | Loads the asset identified by the key as the requested type. |