Class SharedTableData
The SharedTableData holds data that is accessible across all tables. It is responsible for the localization keys and associating the keys to unique ids. Each collection of tables will reference a single SharedTableData asset.
Namespace: UnityEngine.Localization.Tables
Syntax
public class SharedTableData : ScriptableObject, ISerializationCallbackReceiver
Fields
EmptyId
Represents an empty or null Key Id.
Declaration
public const uint EmptyId = 0U
Field Value
Type | Description |
---|---|
UInt32 |
Properties
Entries
All entries.
Declaration
public List<SharedTableData.SharedTableEntry> Entries { get; }
Property Value
Type | Description |
---|---|
List<SharedTableData.SharedTableEntry> |
Metadata
Metadata that is shared between all tables.
Declaration
public MetadataCollection Metadata { get; set; }
Property Value
Type | Description |
---|---|
MetadataCollection |
TableCollectionName
The name of this table collection. All LocalizedTable that use this SharedTableData will have this name.
Declaration
public string TableCollectionName { get; }
Property Value
Type | Description |
---|---|
String |
TableCollectionNameGuid
A unique Id that will never change. Comes from the SharedTableData asset Guid. Provides a way to reference a table that will not be broken if the table collection name was to be changed.
Declaration
public Guid TableCollectionNameGuid { get; }
Property Value
Type | Description |
---|---|
Guid |
Methods
AddKey()
Adds a new key to this SharedTableData with a default name.
Declaration
public SharedTableData.SharedTableEntry AddKey()
Returns
Type | Description |
---|---|
SharedTableData.SharedTableEntry |
AddKey(String)
Adds a new key to this SharedTableData if one does not already exists with the same value. Duplicates are not allowed.
Declaration
public SharedTableData.SharedTableEntry AddKey(string key)
Parameters
Type | Name | Description |
---|---|---|
String | key |
Returns
Type | Description |
---|---|
SharedTableData.SharedTableEntry | The new key or null if the key is already in use. |
AddKey(String, UInt32)
Adds a new key to this SharedTableData if one does not already exists with the same name and id. Duplicates are not allowed.
Declaration
public SharedTableData.SharedTableEntry AddKey(string key, uint id)
Parameters
Type | Name | Description |
---|---|---|
String | key | The unique key name to assign to the entry. |
UInt32 | id | The unique id to assign to the key. |
Returns
Type | Description |
---|---|
SharedTableData.SharedTableEntry | The new entry or null if an entry already exists with the key or id. |
Contains(String)
Is the key value used by any entries in this SharedTableData?
Declaration
public bool Contains(string key)
Parameters
Type | Name | Description |
---|---|---|
String | key | Key to check. |
Returns
Type | Description |
---|---|
Boolean |
Contains(UInt32)
Is the Id value used by any entries in this SharedTableData?
Declaration
public bool Contains(uint id)
Parameters
Type | Name | Description |
---|---|---|
UInt32 | id | Id to check. |
Returns
Type | Description |
---|---|
Boolean |
FindSimilarKey(String, out Int32)
Returns the SharedTableData.SharedTableEntry that is the most similar to the text. Uses the Levenshtein distance method.
Declaration
public SharedTableData.SharedTableEntry FindSimilarKey(string text, out int distance)
Parameters
Type | Name | Description |
---|---|---|
String | text | The text to match against. |
Int32 | distance | The number of edits needed to turn |
Returns
Type | Description |
---|---|
SharedTableData.SharedTableEntry | The SharedTableData.SharedTableEntry that is the most similar to the text or null if one could not be found. |
GenerateUniqueId()
Returns a new unique id for this SharedTableData.
Declaration
protected virtual uint GenerateUniqueId()
Returns
Type | Description |
---|---|
UInt32 |
GetEntry(String)
Returns the Entry for the key, this contains all data for the key.
Declaration
public SharedTableData.SharedTableEntry GetEntry(string key)
Parameters
Type | Name | Description |
---|---|---|
String | key | The name of the key. |
Returns
Type | Description |
---|---|
SharedTableData.SharedTableEntry | The found key entry or null if one can not be found. |
GetEntry(UInt32)
Returns the Entry for the key id, this contains all data for the key.
Declaration
public SharedTableData.SharedTableEntry GetEntry(uint id)
Parameters
Type | Name | Description |
---|---|---|
UInt32 | id | Id the key belongs to. |
Returns
Type | Description |
---|---|
SharedTableData.SharedTableEntry | The found key entry or null if one can not be found. |
GetEntryFromReference(TableEntryReference)
Returns the Entry for the key id, this contains all data for the key.
Declaration
public SharedTableData.SharedTableEntry GetEntryFromReference(TableEntryReference tableEntryReference)
Parameters
Type | Name | Description |
---|---|---|
TableEntryReference | tableEntryReference |
Returns
Type | Description |
---|---|
SharedTableData.SharedTableEntry | The found key entry or null if one can not be found. |
GetId(String)
Get the unique Id for the key name from the shared table data.
Declaration
public uint GetId(string key)
Parameters
Type | Name | Description |
---|---|---|
String | key | The key whose id is being requested. |
Returns
Type | Description |
---|---|
UInt32 | The keys id value or EmptyId if one does not exist. |
GetId(String, Boolean)
Get the unique Id for the key name, if one does not exist then a new entry is added.
Declaration
public uint GetId(string key, bool addNewKey)
Parameters
Type | Name | Description |
---|---|---|
String | key | |
Boolean | addNewKey |
Returns
Type | Description |
---|---|
UInt32 |
GetKey(UInt32)
Get the key associated with the id.
Declaration
public string GetKey(uint id)
Parameters
Type | Name | Description |
---|---|---|
UInt32 | id | Id the key belongs to. |
Returns
Type | Description |
---|---|
String | The found key or null if one can not be found. |
OnAfterDeserialize()
Converts the serializable string into a Guid.
Declaration
public void OnAfterDeserialize()
OnBeforeSerialize()
Converts the Guid into a serializable string.
Declaration
public void OnBeforeSerialize()
RemoveKey(String)
Attempts to remove the key from this SharedTableData.
Declaration
public void RemoveKey(string key)
Parameters
Type | Name | Description |
---|---|---|
String | key | The key to be removed. |
RemoveKey(UInt32)
Attempts to remove the key with provided id.
Declaration
public void RemoveKey(uint id)
Parameters
Type | Name | Description |
---|---|---|
UInt32 | id |
RenameKey(String, String)
Rename the key value if it exists.
Declaration
public void RenameKey(string oldValue, string newValue)
Parameters
Type | Name | Description |
---|---|---|
String | oldValue | |
String | newValue |
RenameKey(UInt32, String)
Rename the key value for the provided id if it exists.
Declaration
public void RenameKey(uint id, string newValue)
Parameters
Type | Name | Description |
---|---|---|
UInt32 | id | |
String | newValue |
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String |