Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


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

The stable id of the key to rename.

newKey

The new key text.

Returns

Type

Description

bool
true
when the key was renamed or already had the requested name; otherwise,
false
.

Remarks

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