AssetProvider
An ordered chain of asset providers used to load localized assets. Providers are tried in order and the first one to resolve an asset wins.
Read time 1 minuteLast updated 10 days ago
Definition
- Type: Class
- Namespace: Unity.Localization.Providers
- Assembly: UnityEngine.LocalizationRuntimeModule
- Implements: ISerializationCallbackReceiver
public sealed class AssetProvider : ISerializationCallbackReceiver
Remarks
The localization settings hold a single instance whose provider list is configurable in the inspector. Add providers such as ReferencedAssetProvider (direct references), ResourceFolderProvider, or an Addressables-backed provider from a package. Each provider resolves an AssetKey in its own way, so ordering decides which one answers a given address. The AssetProvider.Selected provider is the default target for new content authored in the editor.
Build a chain, choose the default provider, then look one up by type.
Examples
using Unity.Localization.Providers;using UnityEngine;namespace Unity.Localization.Samples{ public class AssetProviderOverviewExample { public void Run() { var chain = new AssetProvider(); chain.AddProvider(new ReferencedAssetProvider()); chain.AddProvider(new ResourceFolderProvider()); chain.Selected = chain.GetProvider<ReferencedAssetProvider>(); Debug.Log(chain.Selected is ReferencedAssetProvider); // True } }}
Constructors
Constructor | Description |
|---|---|
| AssetProvider() | Creates an empty chain. |
Properties
Property | Description |
|---|---|
| Providers | The providers, in the order they are tried. |
| Selected | The selected provider: the entry used as the default for new content, or null when none is chosen. |
Methods
Method | Description |
|---|---|
| AddProvider | Adds a provider to the end of the chain. |
| GetProvider | Returns the first provider of the given type in the chain, or null when there is none. |
| InsertProvider | Inserts a provider at the given position in the chain. |
| RemoveProvider | Removes a provider from the chain. |