Hello. I wants get all available locales in Start() method, but it returned me 0. How i can fix this problem?
public class Localization : MonoBehaviour
{
public static Localization Instance;
private void Awake()
{
if (Instance == null)
{
DontDestroyOnLoad(gameObject);
Instance = this;
}
else if (Instance != this)
{
Destroy (gameObject);
}
}
private void Start()
{
Debug.Log("Count: " + GetAvailableLocales().Count);
//SetLocale(Instance.GetAvailableLocales().Where(x => x.Identifier.Code == TransferData.Instance.UserData.Settings.LocaleCode).First());
}
public string GetUIString(string tableArgument) => LocalizationSettings.StringDatabase.GetLocalizedString("UI", tableArgument);
public List<Locale> GetAvailableLocales() => LocalizationSettings.Instance.GetAvailableLocales().Locales;
public Locale GetCurrentLocale() => LocalizationSettings.SelectedLocale;
public void SetLocale(Locale locale) => LocalizationSettings.SelectedLocale = locale;
}
If I want to get the available languages later, let’s say when I open the settings, it works fine, it returns 2 available languages.