RenameKey(long, string)
Renames a key while keeping its id.
Read time 1 minuteLast updated 18 days ago
Definition
- Type: Method
- Namespace: Unity.Localization
- Assembly: UnityEngine.LocalizationRuntimeModule
public bool RenameKey(long id, string newKey)
Parameters
Returns
Type | Description |
|---|---|
| bool | |
Remarks
The key's stable id does not change, so existing translations keyed by id continue to resolve. Returns when the new name is empty, no key uses the id, or another key already uses the new name. Renaming a key to its current name succeeds and makes no change.
falseAdditional Resources: SharedTableData.AddKey, SharedTableData.GetId
Fix a typo in a key without changing its id.
Examples
using Unity.Localization;using UnityEngine;namespace Unity.Localization.Samples{ public class SharedTableDataRenameKeyExample { public void Run() { var sharedData = ScriptableObject.CreateInstance<SharedTableData>(); long id = sharedData.AddKey("GREETNIG").Id; // typo bool renamed = sharedData.RenameKey(id, "GREETING"); Debug.Log(renamed); // True Debug.Log(sharedData.GetKey(id)); // GREETING, same id } }}