Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


SharedTableData

The shared key table for a localization table collection: the set of string keys and their stable ids that every per-locale table in the collection uses.
Read time 5 minutesLast updated 4 days ago

Definition

[HelpURL("localization/localization-tables")]public sealed class SharedTableData : ScriptableObject, ISerializationCallbackReceiver

Remarks

Each key maps to a stable
long
id that never changes for the life of the key, so renaming a key keeps its translations intact. Ids come from the SharedTableData.KeyGenerator, a DistributedUIDGenerator by default, so they are non-sequential and an id of
0
means "no key". Every per-locale ResourceTable in the collection stores its values against these ids. Add and look up keys with SharedTableData.AddKey, SharedTableData.GetId, and SharedTableData.GetKey, and rename in place with SharedTableData.RenameKey. This type derives from ScriptableObject, so create an instance with ScriptableObject factory methods rather than the
new
operator.
Create shared data, add a key, and resolve between key text and id.

Examples

using Unity.Localization;using UnityEngine;namespace Unity.Localization.Samples{ public class SharedTableDataOverviewExample { public void Run() { var sharedData = ScriptableObject.CreateInstance<SharedTableData>(); sharedData.TableCollectionName = "UI Text"; SharedTableData.SharedTableEntry entry = sharedData.AddKey("GREETING"); long id = entry.Id; Debug.Log(sharedData.GetId("GREETING")); // the same id Debug.Log(sharedData.GetKey(id)); // GREETING } }}

Properties

Property

Description

EntriesThe keys in this shared data, in their current order.
KeyGeneratorThe generator that assigns stable ids to new keys.
MetadataCollection-level metadata shared across all locale tables.
TableCollectionNameThe name of the table collection this shared data belongs to.
TableCollectionNameGuidThe asset guid of the table collection.

Methods

Method

Description

AddKeyAdds a key and returns its entry.
ClearRemoves every key from the shared data.
GetEntryReturns the entry for a stable id.
GetIdReturns the stable id for a key.
GetKeyReturns the key text for a stable id.
IsSmartReturns whether a key is marked as a Smart String.
RemoveKeyRemoves a key from the shared data.
RenameKeyRenames a key while keeping its id.
SetKeyOrderReorders the keys to match a given sequence of ids.

Classes

Class

Description

SharedTableData.SharedTableEntryA single key in the shared data, pairing the key text with its stable id.

Inheritance

Inherited Members

Operators

Operator

Description

operator ==Compares two object references to see if they refer to the same object.
boolDetermines whether the object exists.
operator !=Compares if two objects refer to a different object.