Version: Unity 6.7 Alpha (6000.7)
LanguageEnglish
  • C#

LocalizationSettings.InitializeAsync

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public static Awaitable InitializeAsync();

Returns

Awaitable An awaitable that completes when initialization has finished, or immediately when it has already run.

Description

Loads the available locales and selects the startup locale, running once.

Discovers locales that the asset providers expose through ILocaleDiscovery and adds them to the registered LocalizationSettings.AvailableLocales, then selects the startup locale by evaluating the LocalizationSettings.StartupSelectors in order (skipping disabled locales) and falling back to LocalizationSettings.ProjectLocale. Initialization runs only once; the first synchronous or asynchronous resolve through the LocalizationSettings.Database triggers it automatically, so calling this explicitly is only needed when you want to await completion. When it finishes it raises LocalizationSettings.InitializationCompleted.

<para>Waits for localization to be ready before resolving a string.</para>

using Unity.Localization;
using UnityEngine;

namespace Unity.Localization.Samples { public class InitializeAsyncExample : MonoBehaviour { async void Start() { await LocalizationSettings.InitializeAsync(); string title = await LocalizationSettings.ResourceDatabase.GetLocalizedStringAsync("UI Text", "title"); Debug.Log(title); } } }