Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


SelectedLocaleChanged

Raised after the selected locale changes.
Read time 1 minuteLast updated 13 days ago

Definition

  • Type: Event
  • Namespace: Unity.Localization
  • Assembly: UnityEngine.LocalizationRuntimeModule
[AutoStaticsCleanup]public static event Action<Locale> SelectedLocaleChanged

Remarks

Subscribe to this static event to update UI or reload content when the user switches language. It is invoked after LocalizationSettings.SelectedLocale has changed, both during startup selection and on later changes; the new locale is passed to the handler. Because it is static, unsubscribe when your object is destroyed to avoid leaks. To run code once when initialization finishes instead, use LocalizationSettings.InitializationCompleted.
Refreshes a label whenever the locale changes.

Examples

using Unity.Localization;using UnityEngine;namespace Unity.Localization.Samples{ public class SelectedLocaleChangedExample : MonoBehaviour { void OnEnable() => LocalizationSettings.SelectedLocaleChanged += OnLocaleChanged; void OnDisable() => LocalizationSettings.SelectedLocaleChanged -= OnLocaleChanged; void OnLocaleChanged(Locale locale) => Debug.Log($"Locale is now {locale?.Code}"); }}