Version: Unity 6.7 Alpha (6000.7)
LanguageEnglish
  • C#

IAsyncAssetProvider

interface in Unity.Localization.Providers


Implements interfaces:IAssetProvider

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

An optional capability for an asset provider that loads assets asynchronously.

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

<para>A provider that resolves its assets through an asynchronous operation.</para>

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) { } } }

Public Methods

Method Description
LoadAssetAsync Loads the asset identified by the key as the requested type.