# 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.

## Definition

* **Type:** Class
* **Namespace:** [Unity.Localization](/engine/6000.7/script-reference/unity/localization.md)
* **Assembly:** UnityEngine.LocalizationRuntimeModule
* **Inherits from:** [ScriptableObject](/engine/6000.7/script-reference/unityengine/scriptableobject.md)
* **Implements:** [ISerializationCallbackReceiver](/engine/6000.7/script-reference/unityengine/iserializationcallbackreceiver.md)

```csharp
[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](/engine/6000.7/script-reference/unity/localization/sharedtabledata/keygenerator.md), a [DistributedUIDGenerator](/engine/6000.7/script-reference/unity/localization/distributeduidgenerator.md) by default, so they are non-sequential and an id of `0` means "no key". Every per-locale [ResourceTable](/engine/6000.7/script-reference/unity/localization/resourcetable.md) in the collection stores its values against these ids. Add and look up keys with [SharedTableData.AddKey](/engine/6000.7/script-reference/unity/localization/sharedtabledata/addkey.md), [SharedTableData.GetId](/engine/6000.7/script-reference/unity/localization/sharedtabledata/getid.md), and [SharedTableData.GetKey](/engine/6000.7/script-reference/unity/localization/sharedtabledata/getkey.md), and rename in place with [SharedTableData.RenameKey](/engine/6000.7/script-reference/unity/localization/sharedtabledata/renamekey.md). This type derives from [ScriptableObject](/engine/6000.7/script-reference/unityengine/scriptableobject.md), so create an instance with [ScriptableObject](/engine/6000.7/script-reference/unityengine/scriptableobject.md) factory methods rather than the `new` operator.

Additional Resources: [SharedTableData.SharedTableEntry](/engine/6000.7/script-reference/unity/localization/sharedtabledata/sharedtableentry.md), [SharedEntryFlags](/engine/6000.7/script-reference/unity/localization/sharedentryflags.md), [IKeyGenerator](/engine/6000.7/script-reference/unity/localization/ikeygenerator.md), [ResourceTable](/engine/6000.7/script-reference/unity/localization/resourcetable.md)

Create shared data, add a key, and resolve between key text and id.

## Examples

```csharp
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                                                   |
| ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------- |
| [Entries](/engine/6000.7/script-reference/unity/localization/sharedtabledata/entries.md)                                 | The keys in this shared data, in their current order.         |
| [KeyGenerator](/engine/6000.7/script-reference/unity/localization/sharedtabledata/keygenerator.md)                       | The generator that assigns stable ids to new keys.            |
| [Metadata](/engine/6000.7/script-reference/unity/localization/sharedtabledata/metadata.md)                               | Collection-level metadata shared across all locale tables.    |
| [TableCollectionName](/engine/6000.7/script-reference/unity/localization/sharedtabledata/tablecollectionname.md)         | The name of the table collection this shared data belongs to. |
| [TableCollectionNameGuid](/engine/6000.7/script-reference/unity/localization/sharedtabledata/tablecollectionnameguid.md) | The asset guid of the table collection.                       |

## Methods

| Method                                                                                           | Description                                         |
| ------------------------------------------------------------------------------------------------ | --------------------------------------------------- |
| [AddKey](/engine/6000.7/script-reference/unity/localization/sharedtabledata/addkey.md)           | Adds a key and returns its entry.                   |
| [Clear](/engine/6000.7/script-reference/unity/localization/sharedtabledata/clear.md)             | Removes every key from the shared data.             |
| [GetEntry](/engine/6000.7/script-reference/unity/localization/sharedtabledata/getentry.md)       | Returns the entry for a stable id.                  |
| [GetId](/engine/6000.7/script-reference/unity/localization/sharedtabledata/getid.md)             | Returns the stable id for a key.                    |
| [GetKey](/engine/6000.7/script-reference/unity/localization/sharedtabledata/getkey.md)           | Returns the key text for a stable id.               |
| [IsSmart](/engine/6000.7/script-reference/unity/localization/sharedtabledata/issmart.md)         | Returns whether a key is marked as a Smart String.  |
| [RemoveKey](/engine/6000.7/script-reference/unity/localization/sharedtabledata/removekey.md)     | Removes a key from the shared data.                 |
| [RenameKey](/engine/6000.7/script-reference/unity/localization/sharedtabledata/renamekey.md)     | Renames a key while keeping its id.                 |
| [SetKeyOrder](/engine/6000.7/script-reference/unity/localization/sharedtabledata/setkeyorder.md) | Reorders the keys to match a given sequence of ids. |

## Classes

| Class                                                                                                                      | Description                                                               |
| -------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- |
| [SharedTableData.SharedTableEntry](/engine/6000.7/script-reference/unity/localization/sharedtabledata/sharedtableentry.md) | A single key in the shared data, pairing the key text with its stable id. |

## Inheritance

**Inherited Members:**

* [ScriptableObject.CreateInstance(string)](/engine/6000.7/script-reference/unityengine/scriptableobject/createinstance.md#createinstance\(string\))
* [ScriptableObject.CreateInstance(Type)](/engine/6000.7/script-reference/unityengine/scriptableobject/createinstance.md#createinstance\(type\))
* [ScriptableObject.CreateInstance\<T>()](/engine/6000.7/script-reference/unityengine/scriptableobject/createinstance.md)
* [Object.GetEntityId()](/engine/6000.7/script-reference/unityengine/object/getentityid.md)
* [Object.GetHashCode()](/engine/6000.7/script-reference/unityengine/object/gethashcode.md)
* [Object.InstantiateAsync\<T>(T)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, Transform)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, Vector3, Quaternion)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, Transform, Vector3, Quaternion)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Transform)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Vector3, Quaternion)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, ReadOnlySpan\<Vector3>, ReadOnlySpan\<Quaternion>)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Transform, Vector3, Quaternion)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Transform, Vector3, Quaternion, CancellationToken)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Transform, ReadOnlySpan\<Vector3>, ReadOnlySpan\<Quaternion>)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Transform, ReadOnlySpan\<Vector3>, ReadOnlySpan\<Quaternion>, CancellationToken)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, InstantiateParameters, CancellationToken)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, InstantiateParameters, CancellationToken)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, Vector3, Quaternion, InstantiateParameters, CancellationToken)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Vector3, Quaternion, InstantiateParameters, CancellationToken)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, ReadOnlySpan\<Vector3>, ReadOnlySpan\<Quaternion>, InstantiateParameters, CancellationToken)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.Instantiate(Object, Vector3, Quaternion)](/engine/6000.7/script-reference/unityengine/object/instantiate.md#instantiate\(object-vector3-quaternion\))
* [Object.Instantiate(Object, Vector3, Quaternion, Transform)](/engine/6000.7/script-reference/unityengine/object/instantiate.md#instantiate\(object-vector3-quaternion-transform\))
* [Object.Instantiate(Object)](/engine/6000.7/script-reference/unityengine/object/instantiate.md#instantiate\(object\))
* [Object.Instantiate(Object, Scene)](/engine/6000.7/script-reference/unityengine/object/instantiate.md#instantiate\(object-scene\))
* [Object.Instantiate\<T>(T, InstantiateParameters)](/engine/6000.7/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate\<T>(T, Vector3, Quaternion, InstantiateParameters)](/engine/6000.7/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate(Object, Transform)](/engine/6000.7/script-reference/unityengine/object/instantiate.md#instantiate\(object-transform\))
* [Object.Instantiate(Object, Transform, bool)](/engine/6000.7/script-reference/unityengine/object/instantiate.md#instantiate\(object-transform-bool\))
* [Object.Instantiate\<T>(T)](/engine/6000.7/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate\<T>(T, Vector3, Quaternion)](/engine/6000.7/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate\<T>(T, Vector3, Quaternion, Transform)](/engine/6000.7/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate\<T>(T, Transform)](/engine/6000.7/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate\<T>(T, Transform, bool)](/engine/6000.7/script-reference/unityengine/object/instantiate.md)
* [Object.Destroy(Object, float)](/engine/6000.7/script-reference/unityengine/object/destroy.md)
* [Object.DestroyImmediate(Object, bool)](/engine/6000.7/script-reference/unityengine/object/destroyimmediate.md)
* [Object.FindObjectsByType(Type)](/engine/6000.7/script-reference/unityengine/object/findobjectsbytype.md#findobjectsbytype\(type\))
* [Object.FindObjectsByType(Type, FindObjectsInactive)](/engine/6000.7/script-reference/unityengine/object/findobjectsbytype.md#findobjectsbytype\(type-findobjectsinactive\))
* [Object.DontDestroyOnLoad(Object)](/engine/6000.7/script-reference/unityengine/object/dontdestroyonload.md)
* [Object.FindAnyObjectByType\<T>()](/engine/6000.7/script-reference/unityengine/object/findanyobjectbytype.md#findanyobjectbytypet\(\))
* [Object.FindAnyObjectByType\<T>(FindObjectsInactive)](/engine/6000.7/script-reference/unityengine/object/findanyobjectbytype.md#findanyobjectbytypet\(findobjectsinactive\))
* [Object.FindObjectsByType\<T>()](/engine/6000.7/script-reference/unityengine/object/findobjectsbytype.md#findobjectsbytypet\(\))
* [Object.FindObjectsByType\<T>(FindObjectsInactive)](/engine/6000.7/script-reference/unityengine/object/findobjectsbytype.md#findobjectsbytypet\(findobjectsinactive\))
* [Object.FindAnyObjectByType(Type)](/engine/6000.7/script-reference/unityengine/object/findanyobjectbytype.md#findanyobjectbytype\(type\))
* [Object.FindAnyObjectByType(Type, FindObjectsInactive)](/engine/6000.7/script-reference/unityengine/object/findanyobjectbytype.md#findanyobjectbytype\(type-findobjectsinactive\))
* [Object.ToString()](/engine/6000.7/script-reference/unityengine/object/tostring.md)
* [Object.name](/engine/6000.7/script-reference/unityengine/object/name.md)
* [Object.hideFlags](/engine/6000.7/script-reference/unityengine/object/hideflags.md)

### Operators

| Operator                                                                           | Description                                                             |
| ---------------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
| [operator ==](/engine/6000.7/script-reference/unityengine/object/op-equality.md)   | Compares two object references to see if they refer to the same object. |
| [bool](/engine/6000.7/script-reference/unityengine/object/op-implicit.md)          | Determines whether the object exists.                                   |
| [operator !=](/engine/6000.7/script-reference/unityengine/object/op-inequality.md) | Compares if two objects refer to a different object.                    |
