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

IResourceEntry

interface in Unity.Localization

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

Description

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

Properties

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.