LocalizeStringListEvent
Component that resolves a localized string list and forwards it through a UnityEvent whenever a value or the selected locale changes.
Read time 7 minutesLast updated 2 months ago
Definition
- Type: Class
- Namespace: Unity.Localization.Components
- Assembly: UnityEngine.LocalizationRuntimeModule
- Inherits from: MonoBehaviour
[AddComponentMenu("Localization/Localize String List Event")]public class LocalizeStringListEvent : MonoBehaviour
Remarks
Add this component to a GameObject, assign its LocalizeStringListEvent.ListReference in the Inspector, then connect LocalizeStringListEvent.OnUpdateList to whatever displays the values, for example a dropdown's options. The reference accepts either kind of list: a LocalizedStringList splits one entry on a separator, and a LocalizedStringGroup combines several entries.
Forward the resolved values to a dropdown.
Examples
using System.Collections.Generic;using Unity.Localization.Components;using UnityEngine;namespace Unity.Localization.Samples{ public class LocalizeStringListEventBindingExample : MonoBehaviour { public LocalizeStringListEvent localize; readonly List<string> m_Options = new(); void OnEnable() => localize.OnUpdateList.AddListener(OnUpdate); void OnDisable() => localize.OnUpdateList.RemoveListener(OnUpdate); void OnUpdate(List<string> values) { m_Options.Clear(); m_Options.AddRange(values); } }}
Properties
Property | Description |
|---|---|
| ListReference | The localized string list reference to resolve. |
| OnUpdateList | The event invoked with the localized values each time the list resolves. |
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. |