IAssetProvider
The base capability shared by asset providers in the localization system.
Read time 1 minuteLast updated 12 days ago
Definition
- Type: Interface
- Namespace: Unity.Localization.Providers
- Assembly: UnityEngine.LocalizationRuntimeModule
public interface IAssetProvider
Remarks
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).
A synchronous provider that resolves assets it already holds in memory.
Examples
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) { } }}
Properties
Property | Description |
|---|---|
| Id | The identifier a table collection uses to name the provider that serves it. |
Methods
Method | Description |
|---|---|
| Release | Releases an asset previously returned by this provider. |