Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


AddEntry(IResourceEntry)

Adds an entry, replacing any existing entry with the same key id.
Read time 1 minuteLast updated 13 days ago

Definition

  • Type: Method
  • Namespace: Unity.Localization
  • Assembly: UnityEngine.LocalizationRuntimeModule
public void AddEntry(IResourceEntry entry)

Parameters

The entry to add.

Remarks

The entry must already carry a non-zero key id, so build it against a key that exists in ResourceTable.SharedData, for example one returned by SharedTableData.AddKey. A
null
entry, or one whose key id is
0
, is ignored. To add a plain string without constructing the entry yourself, use ResourceTable.AddStringEntry.
Add a shared key, then store a string entry for it in this locale.

Examples

using Unity.Localization;using UnityEngine;namespace Unity.Localization.Samples{ public class ResourceTableAddEntryExample { public void Run() { var shared = ScriptableObject.CreateInstance<SharedTableData>(); var table = ScriptableObject.CreateInstance<ResourceTable>(); table.SharedData = shared; table.LocaleIdentifier = "en"; var key = shared.AddKey("Title"); table.AddEntry(new StringEntry(key.Id, "Menu")); Debug.Log(table.GetEntry<IStringEntry>("Title").Value); // Menu } }}