Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


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

longThe key's stable id, or
0
when it is absent.

Remarks

Returns
0
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.
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 } }}