The base capability shared by asset providers in the localization system.
A provider decides how an address resolves to an asset, for example from built content, a Resources folder, or
Addressables. It opts into loading by implementing IAsyncAssetProvider, ISynchronousAssetProvider,
or both; the localization system prefers the asynchronous version and falls back to the synchronous one, and on the
synchronous paths it uses only synchronous providers. Add an implementation to an AssetProvider chain to
make it available. The built-in implementations are ReferencedAssetProvider (synchronous) and
ResourceFolderProvider (both).
Additional resources: IAsyncAssetProvider, ISynchronousAssetProvider, AssetProvider, AssetKey
<para>A synchronous provider that resolves assets it already holds in memory.</para>
using System.Collections.Generic; using Unity.Localization.Providers; using Object = UnityEngine.Object;
namespace Unity.Localization.Samples { public class SyncAssetProviderExample : IAssetProvider, ISynchronousAssetProvider { readonly Dictionary<string, Object> m_Assets = new();
public void Register(string address, Object asset) => m_Assets[address] = asset;
public bool TryLoadAsset<T>(AssetKey key, out T asset) where T : Object { asset = m_Assets.TryGetValue(key.Address, out var value) ? value as T : null; return asset != null; }
public void Release(Object asset) { } } }
| Property | Description |
|---|---|
| Id | The identifier a table collection uses to name the provider that serves it. |
| Method | Description |
|---|---|
| Release | Releases an asset previously returned by this provider. |