Class LocalizedReference
Provides a way to reference a table entry inside of a specific LocalizationTable.
Namespace: UnityEngine.Localization
Syntax
public abstract class LocalizedReference : ISerializationCallbackReceiver
Properties
FallbackState
Can be used to override the default fallback state.
Declaration
public FallbackBehavior FallbackState { get; set; }
Property Value
Type | Description |
---|---|
FallbackBehavior |
IsEmpty
Checks whether both TableReference and TableEntryReference contain valid references, and returns true if one of them is empty.
Declaration
public bool IsEmpty { get; }
Property Value
Type | Description |
---|---|
Boolean |
LocaleOverride
Provide a locale that can be used instead of SelectedLocale.
A null
value will revert to using SelectedLocale.
Declaration
public Locale LocaleOverride { get; set; }
Property Value
Type | Description |
---|---|
Locale |
TableEntryReference
Declaration
public TableEntryReference TableEntryReference { get; set; }
Property Value
Type | Description |
---|---|
TableEntryReference |
Examples
This example shows the 2 ways a reference can be set.
var localizedString = new LocalizedString();
// Table Entry Reference can be set with the name of the Key
localizedString.TableEntryReference = "Exit Game";
// Or the Key Id
localizedString.TableEntryReference = 342423423;
See Also
TableReference
Provides a reference to the LocalizationTable. A table reference can be either the TableCollectionName of the table or the TableCollectionNameGuid.
Declaration
public TableReference TableReference { get; set; }
Property Value
Type | Description |
---|---|
TableReference |
Remarks
Note: Changing this value triggers an update to any subscribers. See SetReference(TableReference, TableEntryReference) if you wish to change both the table and entry.
Examples
This example shows the 2 ways a reference can be set.
var localizedString = new LocalizedString();
// Table Reference can be set with the name of the table
localizedString.TableReference = "My String Table";
// Or the Table Collection Guid
localizedString.TableReference = new System.Guid("6e79ded14bc9e0a4d9bf2b8aac246bfe");
WaitForCompletion
Determines if WaitForCompletion should be used to force loading to be completed immediately. See Synchronous Workflow for further details. Please note that WaitForCompletion is not supported on WebGL.
Declaration
public virtual bool WaitForCompletion { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Methods
ForceUpdate()
Declaration
protected abstract void ForceUpdate()
Reset()
Called when values are changed due to a change made via serialization, such as via the inspector.
Declaration
protected abstract void Reset()
SetReference(TableReference, TableEntryReference)
Sets both the TableReference and TableEntryReference and triggers an update if there are any change subscribers.
Declaration
public void SetReference(TableReference table, TableEntryReference entry)
Parameters
Type | Name | Description |
---|---|---|
TableReference | table | Reference to the TableCollectionName or TableCollectionNameGuid. |
TableEntryReference | entry |
Examples
This example shows the different ways SetReference can be called.
var localizedString = new LocalizedString();
// Setting with names
localizedString.SetReference("UI Text", "Options");
// Setting with the table name and Key Id
localizedString.SetReference("UI Text", 3432444324);
// Setting with the Table Name Guid and Key name
localizedString.SetReference(new System.Guid("6e79ded14bc9e0a4d9bf2b8aac246bfe"), "Options");
// Setting with the Table Name Guid and the Key Id
localizedString.SetReference(new System.Guid("6e79ded14bc9e0a4d9bf2b8aac246bfe"), 3432444324);