| Parameter | Description |
|---|---|
| id | The stable id of the key to rename. |
| newKey | The new key text. |
bool
true when the key was renamed or already had the requested name; otherwise, false.
Renames a key while keeping its id.
The key's stable id does not change, so existing translations keyed by id continue to resolve. Returns
false 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.
Additional resources: SharedTableData.AddKey, SharedTableData.GetId
<para>Fix a typo in a key without changing its id.</para>
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 } } }