Selected locale stuck on on language.
I am implementing localization with the Unity package. Now I set up 3 languages, english, dutch and german. The problem however is that every time i play the game (in editor). It defaults to Dutch, while i selected English as the standard language.
A bigger problem is that when I tried to make buttons for language selection they dont seem to change the language at all, nothing changes. All the string tables, string event is setup properly since if iuse the dropdown menu in game view to change the language it does work.
Anyone any idea what I am doing wrong?
English is setup as default language.
Script for buttons:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Localization.Settings;
/// <summary>
/// Handles changing the game's locale dynamically.
/// </summary>
public class LocaleSelector : MonoBehaviour
{
private bool active = false;
/// <summary>
/// Changes the current locale based on the provided locale ID.
/// </summary>
/// <param name="localeID">The index of the locale in the Available Locales list.</param>
public void ChangeLocale(int localeID)
{
if (active == true)
return;
StartCoroutine(SetLocale(localeID));
}
/// <summary>
/// Coroutine that sets the locale after ensuring the Localization system is initialized.
/// </summary>
/// <param name="localeID">The index of the locale in the Available Locales list.</param>
private IEnumerator SetLocale(int localeID)
{
active = true;
yield return LocalizationSettings.InitializationOperation;
LocalizationSettings.SelectedLocale = LocalizationSettings.AvailableLocales.Locales[localeID];
active = false;
}
}

