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

TableEntryReference

struct 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

A serializable reference to a single table entry, identified either by its key text or by its stable key id.

An entry reference addresses one row inside a table collection without holding a direct object reference. It stores either the key text or the numeric key id; TableEntryReference.ReferenceType reports which form is present, and TableEntryReference.IsEmpty is true when neither is set. Key ids are stable across key renames, so they are the safer choice for serialized data, while key text is more readable in code. Convert between the two forms with TableEntryReference.ResolveKeyId and TableEntryReference.ResolveKeyName, passing the collection's SharedTableData. Combine it with a TableReference to address an entry in a specific collection.

Additional resources: TableReference, ResourceDatabase, ResourceTable

<para>Create entry references by key text and by key id, then resolve one to an id.</para>

using Unity.Localization;
using UnityEngine;

namespace Unity.Localization.Samples { public class TableEntryReferenceOverviewExample { public void Run(SharedTableData sharedData) { TableEntryReference byKey = "Menu/Start"; // implicit conversion from string TableEntryReference byId = 12345L; // implicit conversion from long

long id = byKey.ResolveKeyId(sharedData); Debug.Log($"{id} {byId.KeyId}"); } } }

Properties

Property Description
IsEmpty Whether this reference points at nothing.
Key The key text of the referenced entry, or null when the reference is empty or id-based.
KeyId The stable key id of the referenced entry, or 0 when the reference is empty or name-based.
ReferenceType How this reference identifies its entry.

Public Methods

Method Description
Equals Checks whether this reference identifies the same entry as another.
GetHashCode Computes a hash code for this reference.
ResolveKeyId Resolves this reference to a numeric key id using the given shared table data.
ResolveKeyName Resolves this reference to a key name using the given shared table data.
ToString Returns a readable string describing this reference.

Operators

Operator Description
TableEntryReference Converts key text into a name-based entry reference.
TableEntryReference Converts a key id into an id-based entry reference.