Version: Unity 6.7 Alpha (6000.7)
LanguageEnglish
  • C#

ResourceTable.AddEntry

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public void AddEntry(IResourceEntry entry);

Parameters

Parameter Description
entry The entry to add.

Description

Adds an entry, replacing any existing entry with the same key id.

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.

Additional resources: ResourceTable.AddStringEntry, ResourceTable.RemoveEntry, SharedTableData

<para>Add a shared key, then store a string entry for it in this locale.</para>

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