LocalizeSpriteEvent
Component that resolves a localized sprite and forwards it through a UnityEvent whenever the value or the selected locale changes.
Read time 7 minutesLast updated 8 days ago
Definition
- Type: Class
- Namespace: Unity.Localization.Components
- Assembly: UnityEngine.LocalizationRuntimeModule
- Inherits from: LocalizeAssetEvent<Sprite>
[AddComponentMenu("Localization/Localize Sprite Event")]public class LocalizeSpriteEvent : LocalizeAssetEvent<Sprite>
Remarks
This is the Sprite specialization of LocalizeAssetEvent<TObject>. Add it to a GameObject, assign its LocalizeAssetEvent<TObject>.AssetReference in the Inspector, then connect LocalizeAssetEvent<TObject>.OnUpdateAsset to a sprite renderer or UI image to swap artwork such as icons or illustrations per locale.
Forward the resolved sprite to a sprite renderer.
Examples
using Unity.Localization.Components;using UnityEngine;namespace Unity.Localization.Samples{ public class LocalizeSpriteEventBindingExample : MonoBehaviour { public LocalizeSpriteEvent localize; public SpriteRenderer target; void OnEnable() => localize.OnUpdateAsset.AddListener(OnUpdate); void OnDisable() => localize.OnUpdateAsset.RemoveListener(OnUpdate); void OnUpdate(Sprite value) => target.sprite = 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. |