Localization not working in builds
Hello, I am currently trying to add localization in my games to have 2 languages: english and french.
I followed a tutorial, and it now works in editor mode: I can change language using a dropdown and everything is gravy. But when I build my game, nothing works, and I have error messages in Development build's console.
Here are the errors when my project starts:
And when I try to change language with my dropdown menu:
I want to add that I only have 2 languages in my project and 2 options on my dropdown, and that my adressable assets are correctly located.
Here is the code of my dropdown menu:
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.Localization.Settings;
using UnityEngine.UI;
public class ChangeLanguageMenu : MonoBehaviour
{
public TMP_Dropdown dropdown;
public void Awake()
{
StartCoroutine(coroutineStart());
}
public IEnumerator coroutineStart()
{
yield return LocalizationSettings.InitializationOperation;
if (LocalizationSettings.SelectedLocale == null)
{
LocalizationSettings.SelectedLocale = LocalizationSettings.AvailableLocales.Locales[0];
}
dropdown.value = LocalizationSettings.SelectedLocale.SortOrder;
}
//Called by a dropdown menu when I change the selection, I only have 2 language in this dropdown
public void setLanguage(int languageNumber)
{
StartCoroutine(coroutineSetLanguage(languageNumber));
}
public IEnumerator coroutineSetLanguage(int languageNumber)
{
// Wait for the localization system to initialize, loading Locales, preloading, etc.
yield return LocalizationSettings.InitializationOperation;
LocalizationSettings.SelectedLocale = LocalizationSettings.AvailableLocales.Locales[languageNumber];
}
}
Thanks you in advance for your help.
Answer by pordrack · Apr 14 at 09:13 PM
I fixed it thanks to this article: https://phrase.com/blog/posts/localizing-unity-games-official-localization-package/ I headed to Window->Asset management->Adressables->Groups And then clicked on this: Hope it can help others.