Event SelectedLocaleChanged
Event that is sent when the SelectedLocale is changed.
Namespace: UnityEngine.Localization.Settings
Assembly: Unity.Localization.dll
Syntax
public static event Action<Locale> SelectedLocaleChanged
Returns
Type | Description |
---|---|
Action<Locale> |
Examples
This shows how to keep track of the current selected Locale.
public class SelectedLocaleChangedExample : MonoBehaviour
{
Locale currentLocale;
void OnEnable()
{
LocalizationSettings.SelectedLocaleChanged += OnSelectedLocaleChanged;
}
void OnDisable()
{
LocalizationSettings.SelectedLocaleChanged -= OnSelectedLocaleChanged;
}
IEnumerable Start()
{
// Get the initial selected locale value
var selectedLocale = LocalizationSettings.SelectedLocaleAsync;
yield return selectedLocale;
currentLocale = selectedLocale.Result;
}
void OnSelectedLocaleChanged(Locale locale)
{
currentLocale = locale;
}
void OnGUI()
{
if (currentLocale != null)
GUILayout.Label("The current locale is " + currentLocale.LocaleName);
}
}