Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


LoadingPreference

Selects whether the localization system resolves values asynchronously or synchronously when it has the choice.
Read time 1 minuteLast updated 6 days ago

Definition

  • Type: Enum
  • Namespace: Unity.Localization
  • Assembly: UnityEngine.LocalizationRuntimeModule
public enum LoadingPreference

Remarks

This is the default loading behaviour for the event-driven accessors on the reference types, such as LocalizedString.GetLocalizedStringAsync, LocalizedAsset<TObject>.GetLocalizedAssetAsync(), and LocalizedTable.GetTableAsync, and for the change events that call them. Set it through LocalizationSettings.PreferredLoading. The preference is a hint: when LoadingPreference.Synchronous is chosen but a value cannot be resolved synchronously (for example the table is only available through an asynchronous provider), the accessor falls back to an asynchronous load.
Choose synchronous resolution as the default loading behaviour.

Examples

using Unity.Localization;using UnityEngine;namespace Unity.Localization.Samples{ public class PreferredLoadingExample : MonoBehaviour { [SerializeField] LocalizedString m_Greeting = new(); void OnEnable() { LocalizationSettings.PreferredLoading = LoadingPreference.Synchronous; m_Greeting.StringChanged += OnGreetingChanged; } void OnDisable() => m_Greeting.StringChanged -= OnGreetingChanged; void OnGreetingChanged(string value) => Debug.Log(value); }}

Fields

Value

Description

AsynchronousResolves values through an asynchronous load, deferring the result until the content is available.
SynchronousResolves values synchronously when possible, falling back to an asynchronous load when it is not.