Represents a single entry in a resource table, identified by a stable key id and carrying per-entry metadata.
An entry holds one locale's value for a key. Entries are stored polymorphically in a ResourceTable
through [SerializeReference], so string, asset, and custom kinds share one entry list and new kinds drop in
without changing the table. IResourceEntry.KeyId ties the entry to a shared key in the collection's
SharedTableData, and IResourceEntry.Metadata holds comments and custom properties for that entry.
Fetch an entry from a table with ResourceTable.GetEntry or its overloads, then work with it
through the value interface that matches its kind, IStringEntry or IAssetEntry.
Additional resources: ResourceTable, IStringEntry, IAssetEntry, ResourceEntryBase, SharedTableData
<para>Read the key id and metadata of an entry fetched from a table.</para>
using Unity.Localization; using UnityEngine;
namespace Unity.Localization.Samples { public class IResourceEntryOverviewExample { public void Run() { var shared = ScriptableObject.CreateInstance<SharedTableData>(); shared.TableCollectionName = "UI Text";
var table = ScriptableObject.CreateInstance<ResourceTable>(); table.SharedData = shared; table.LocaleIdentifier = new LocaleIdentifier("en");
table.AddStringEntry("greeting", "Hello"); IResourceEntry entry = table.GetEntry("greeting");
Debug.Log(entry.KeyId); // the stable key id for "greeting" Debug.Log(entry.Metadata.HasData); // False: no metadata attached yet } } }
| Property | Description |
|---|---|
| KeyId | The stable key id this entry provides a value for. |
| Metadata | The metadata attached to this entry, such as comments or custom properties. |
| SharedEntry | The shared key data for this entry, common to the key across every locale. |
| Table | The table this entry belongs to. |