기술 자료

Unity Engine

Unity Engine

InitializeAsync()

Loads the available locales and selects the startup locale, running once.
읽는 시간 1분최근 업데이트: 한 달 전

Definition

  • Type: Method
  • Namespace: Unity.Localization
  • Assembly: UnityEngine.LocalizationRuntimeModule
public static Awaitable InitializeAsync()

Returns

Type

Description

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

Remarks

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.
Waits for localization to be ready before resolving a string.

Examples

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); } }}