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

LocalizedReference

class in Unity.Localization

/

Inherits from:UIElements.CustomBinding

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

The serializable base for a reference into a localization table, pairing a table collection with an optional locale override.

A LocalizedReference identifies the TableReference to resolve against and, optionally, the LocalizedReference.LocaleOverride to resolve in. When no override is set, the reference resolves in the locale selected on LocalizationSettings. Concrete subclasses resolve either a whole table (LocalizedTable) or a single entry within one (LocalizedEntry<T0>, along with the LocalizedString and LocalizedAsset<T0> types built on it). Resolution goes through the ResourceDatabase provider chain, so lookups are asynchronous by default; set LocalizationSettings.PreferredLoading to LoadingPreference.Synchronous to resolve synchronously when the value is available. Store a reference in a serialized field to expose it in the Inspector, then read the localized value at runtime.

Additional resources: LocalizedString, LocalizedAsset<T0>, LocalizedTable, ResourceDatabase, TableReference

<para>Configure a reference through the derived <see cref="Unity.Localization.LocalizedString" /> type and choose the locale it resolves in.</para>

using Unity.Localization;
using UnityEngine;

namespace Unity.Localization.Samples { public class LocalizedReferenceConfigureExample { public void Configure() { var reference = new LocalizedString(); reference.TableReference = "My Strings"; reference.TableEntryReference = "HELLO"; reference.LocaleOverride = new LocaleIdentifier("fr"); } } }

Properties

Property Description
EnableFallback Whether to walk the locale fallback chain when the resolving locale has no value for this reference.
HasLocaleOverride Whether a locale override is set on this reference.
IsEmpty Whether this reference is unset and resolves to no value.
LocaleOverride The locale used to resolve this reference instead of the locale selected in the project settings.
TableReference The localization table collection that this reference resolves against.

Public Methods

Method Description
OnActivated Starts resolving the reference when it becomes active on an element.
OnDeactivated Stops resolving the reference once it is no longer active on any element.
Update Writes the resolved value to the bound field.

Protected Methods

Method Description
ForceUpdate Called when the reference changes so subclasses can refresh any live listeners.
ResolveOverrideLocale Resolves the override locale from the project settings for subclasses to pass to the resource database.

Inherited Members

Properties

PropertyDescription
isDirty When set to true, the binding instance updates during the next update cycle. When set to false, the binding instance updates only if a change is detected.
updateTrigger When set to BindingUpdateTrigger.EveryUpdate, the binding instance updates in every update, regardless of the data source version.

Public Methods

MethodDescription
MarkDirty Notifies the binding system to process this binding.
OnDataSourceChanged Called when the resolved data source of a binding changes.

Static Methods

MethodDescription
GetGlobalLogLevel Gets the global log level for all binding failures.
GetPanelLogLevel Gets the log level for binding failures on a panel.
ResetPanelLogLevel Resets the log level for binding failures on a panel to use the global setting.
SetGlobalLogLevel Sets the log level for all binding failures.
SetPanelLogLevel Sets the log level for binding failures on a panel.