GetId(string)
Returns the stable id for a key.
Read time 1 minuteLast updated 12 days ago
Definition
- Type: Method
- Namespace: Unity.Localization
- Assembly: UnityEngine.LocalizationRuntimeModule
public long GetId(string key)
Parameters
The key to look up.
Returns
Type | Description |
|---|---|
| long | The key's stable id, or |
Remarks
Returns when the key is empty, null, or not present. Ids are stable across renames, so store the id rather than the key text when you need a reference that survives a rename.
0Additional Resources: SharedTableData.GetKey, SharedTableData.GetEntry
Look up the id assigned to a key.
Examples
using Unity.Localization;using UnityEngine;namespace Unity.Localization.Samples{ public class SharedTableDataGetIdExample { public void Run() { var sharedData = ScriptableObject.CreateInstance<SharedTableData>(); sharedData.AddKey("GREETING"); long id = sharedData.GetId("GREETING"); // the key's stable id long missing = sharedData.GetId("UNKNOWN"); // 0 Debug.Log(id != 0); // True Debug.Log(missing); // 0 } }}