Interface IEntryOverride
Metadata that can be applied to SharedTableData.SharedTableEntry or a table entry to override the entry when loading a localized value.
Namespace: UnityEngine.Localization.Metadata
Syntax
public interface IEntryOverride : IMetadata
Remarks
When fetching a localized value, an Entry Override can be used to redirect to a different table entry, such as when running on a certain platform or in a specific region. The Entry Override is evaluated during GetTableEntryAsync(TableReference, TableEntryReference, Locale, FallbackBehavior). The table entry will first be checked for an override and then the SharedTableData.SharedTableEntry. See also PlatformOverride
Examples
This example shows how to create an override that will be applied on a chosen day of the week.
[Serializable]
[Metadata(AllowedTypes = MetadataType.AllTableEntries | MetadataType.StringTableEntry)]
public class DayOverride : IEntryOverride
{
public LocalizedString myOverride = new LocalizedString();
public DayOfWeek day = DayOfWeek.Friday;
public EntryOverrideType GetOverride(out TableReference tableReference, out TableEntryReference tableEntryReference)
{
if (DateTime.Now.DayOfWeek == day)
{
tableReference = myOverride.TableReference;
tableEntryReference = myOverride.TableEntryReference;
return EntryOverrideType.TableAndEntry;
}
// Do not override.
tableReference = default;
tableEntryReference = default;
return EntryOverrideType.None;
}
}
Methods
GetOverride(out TableReference, out TableEntryReference)
Determines if the table, entry or both should be overridden.
Declaration
EntryOverrideType GetOverride(out TableReference tableReference, out TableEntryReference tableEntryReference)
Parameters
Type | Name | Description |
---|---|---|
TableReference | tableReference | The table to use or default if it is not overriden. |
TableEntryReference | tableEntryReference | The entry to use or default if it is not overriden. |
Returns
Type | Description |
---|---|
EntryOverrideType | Returns the fields that should be overridden. |