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.
Inherited Members
Namespace: UnityEngine.Localization.Tables
Syntax
public class SharedTableData : ScriptableObject, ISerializationCallbackReceiver
Fields
EmptyId
Represents an empty or null Key Id.
Declaration
public const long EmptyId = 0L
Field Value
Type | Description |
---|---|
Int64 |
Properties
Entries
All entries.
Declaration
public List<SharedTableData.SharedTableEntry> Entries { get; }
Property Value
Type | Description |
---|---|
List<SharedTableData.SharedTableEntry> |
KeyGenerator
The Key Generator to use when adding new entries. By default this will use DistributedUIDGenerator.
Declaration
public IKeyGenerator KeyGenerator { get; set; }
Property Value
Type | Description |
---|---|
IKeyGenerator |
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 LocalizationTable 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, Int64)
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, long id)
Parameters
Type | Name | Description |
---|---|---|
String | key | The unique key name to assign to the entry. |
Int64 | 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(Int64)
Is the Id value used by any entries in this SharedTableData?
Declaration
public bool Contains(long id)
Parameters
Type | Name | Description |
---|---|---|
Int64 | id | Id to check. |
Returns
Type | Description |
---|---|
Boolean |
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 |
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. |
GetEntry(Int64)
Returns the Entry for the key id, this contains all data for the key.
Declaration
public SharedTableData.SharedTableEntry GetEntry(long id)
Parameters
Type | Name | Description |
---|---|---|
Int64 | id | Id the key belongs to. |
Returns
Type | Description |
---|---|
SharedTableData.SharedTableEntry | The found key entry or null if one can not be found. |
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. |
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 long GetId(string key)
Parameters
Type | Name | Description |
---|---|---|
String | key | The key whose id is being requested. |
Returns
Type | Description |
---|---|
Int64 | 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 long GetId(string key, bool addNewKey)
Parameters
Type | Name | Description |
---|---|---|
String | key | |
Boolean | addNewKey |
Returns
Type | Description |
---|---|
Int64 | Id of the Key that exists else the Id of the newly created Key if addNewKey is True or EmptyId. |
GetKey(Int64)
Get the key associated with the id.
Declaration
public string GetKey(long id)
Parameters
Type | Name | Description |
---|---|---|
Int64 | 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()
Implements
OnBeforeSerialize()
Converts the Guid into a serializable string.
Declaration
public void OnBeforeSerialize()
Implements
RemapId(Int64, Int64)
Attempts to change the Id of an entry.
Declaration
public bool RemapId(long currentId, long newId)
Parameters
Type | Name | Description |
---|---|---|
Int64 | currentId | The current Id that should be changed. Must exist. |
Int64 | newId | The new Id to use. Must not already be in use. |
Returns
Type | Description |
---|---|
Boolean | True is the Id was changed successfully. |
RemoveKey(Int64)
Attempts to remove the key with provided id.
Declaration
public void RemoveKey(long id)
Parameters
Type | Name | Description |
---|---|---|
Int64 | id |
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. |
RenameKey(Int64, String)
Rename the key value for the provided id if it exists.
Declaration
public void RenameKey(long id, string newValue)
Parameters
Type | Name | Description |
---|---|---|
Int64 | id | |
String | newValue |
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 |
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String |