Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


PreferredLoading

The default loading behaviour used by the reference accessors and their change events.
Read time 1 minuteLast updated 6 days ago

Definition

  • Type: Property
  • Namespace: Unity.Localization
  • Assembly: UnityEngine.LocalizationRuntimeModule
public static LoadingPreference PreferredLoading { get; set; }

Remarks

Defaults to LoadingPreference.Asynchronous. When set to LoadingPreference.Synchronous, the event-driven accessors (LocalizedString.GetLocalizedStringAsync, LocalizedAsset<TObject>.GetLocalizedAssetAsync(), and LocalizedTable.GetTableAsync) resolve synchronously when the value is available, and fall back to an asynchronous load when it is not. When no settings instance is registered, this reads as LoadingPreference.Asynchronous.
Additional Resources: LoadingPreference
Make localized references resolve synchronously by default.

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