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

LoadingPreference

enumeration

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

Description

Selects whether the localization system resolves values asynchronously or synchronously when it has the choice.

This is the default loading behaviour for the event-driven accessors on the reference types, such as LocalizedString.GetLocalizedStringAsync, LocalizedAsset<T0>.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.

Additional resources: LocalizationSettings.PreferredLoading

<para>Choose synchronous resolution as the default loading behaviour.</para>

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

Properties

Property Description
Asynchronous Resolves values through an asynchronous load, deferring the result until the content is available.
Synchronous Resolves values synchronously when possible, falling back to an asynchronous load when it is not.