LocalizeTextureEvent
Component that resolves a localized texture and forwards it through a UnityEvent whenever the value or the selected locale changes.
Read time 7 minutesLast updated 10 days ago
Definition
- Type: Class
- Namespace: Unity.Localization.Components
- Assembly: UnityEngine.LocalizationRuntimeModule
- Inherits from: LocalizeAssetEvent<Texture>
[AddComponentMenu("Localization/Localize Texture Event")]public class LocalizeTextureEvent : LocalizeAssetEvent<Texture>
Remarks
This is the Texture specialization of LocalizeAssetEvent<TObject>. Add it to a GameObject, assign its LocalizeAssetEvent<TObject>.AssetReference in the Inspector, then connect LocalizeAssetEvent<TObject>.OnUpdateAsset to an image component to swap textures such as flags or localized artwork per locale.
Forward the resolved texture to a UI image.
Examples
using Unity.Localization.Components;using UnityEngine;namespace Unity.Localization.Samples{ public class LocalizeTextureEventBindingExample : MonoBehaviour { public LocalizeTextureEvent localize; public Renderer target; void OnEnable() => localize.OnUpdateAsset.AddListener(OnUpdate); void OnDisable() => localize.OnUpdateAsset.RemoveListener(OnUpdate); void OnUpdate(Texture value) => target.material.mainTexture = value; }}
Inheritance
Operators
Operator | Description |
|---|---|
| operator == | Compares two object references to see if they refer to the same object. |
| bool | Determines whether the object exists. |
| operator != | Compares if two objects refer to a different object. |