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

AssetProvider

class in Unity.Localization.Providers


Implements interfaces:ISerializationCallbackReceiver

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 ordered chain of asset providers used to load localized assets. Providers are tried in order and the first one to resolve an asset wins.

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.

Additional resources: IAssetProvider, AssetKey, ReferencedAssetProvider, ResourceFolderProvider

<para>Build a chain, choose the default provider, then look one up by type.</para>

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

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.

Constructors

Constructor Description
AssetProvider Creates an empty chain.

Public 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.