Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


LocalizedAsset<TObject>

A serializable reference to a localized asset that updates as the selected locale changes.
Read time 2 minutesLast updated 12 days ago

Definition

public class LocalizedAsset<TObject> : LocalizedEntry<IAssetEntry> where TObject : Object

Remarks

A LocalizedAsset<TObject> extends LocalizedEntry<TEntry> to resolve an IAssetEntry and load its asset as
TObject
through the ResourceDatabase provider chain. Load the asset with LocalizedAsset<TObject>.GetLocalizedAssetAsync(), or subscribe to LocalizedAsset<TObject>.AssetChanged to receive it immediately and again whenever the selected locale changes. For common asset types, use the LocalizedTexture, LocalizedGameObject, and LocalizedObject subclasses, which are serializable and appear in the Inspector.
Resolve a localized texture and apply it whenever the locale changes.

Examples

using Unity.Localization;using UnityEngine;namespace Unity.Localization.Samples{ public class LocalizedAssetTextureExample : MonoBehaviour { void OnEnable() { var targetRenderer = GetComponent<Renderer>(); var icon = new LocalizedTexture(); icon.SetReference("My Assets", "ICON"); icon.AssetChanged += texture => targetRenderer.material.mainTexture = texture; } }}

Methods

Method

Description

GetLocalizedAssetResolves the localized asset synchronously when a synchronous provider and entry can supply it.
GetLocalizedAssetAsyncLoads the localized asset asynchronously through the resource database.
RefreshAssetRe-resolves the asset and pushes the result to subscribers.

Events

Member

Description

AssetChangedOccurs when the resolved asset changes, and once immediately when a handler subscribes.

Delegates

Delegate

Description

LocalizedAsset<TObject>.ChangeHandlerRepresents a method that receives a resolved localized asset value.

Inheritance