Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


TableEntryReference

A serializable reference to a single table entry, identified either by its key text or by its stable key id.
Read time 2 minutesLast updated 6 days ago

Definition

public struct TableEntryReference : IEquatable<TableEntryReference>

Remarks

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.
Create entry references by key text and by key id, then resolve one to an id.

Examples

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

IsEmptyWhether this reference points at nothing.
KeyThe key text of the referenced entry, or null when the reference is empty or id-based.
KeyIdThe stable key id of the referenced entry, or 0 when the reference is empty or name-based.
ReferenceTypeHow this reference identifies its entry.

Methods

Method

Description

EqualsChecks whether this reference equals another object.
GetHashCodeComputes a hash code for this reference.
ResolveKeyIdResolves this reference to a numeric key id using the given shared table data.
ResolveKeyNameResolves this reference to a key name using the given shared table data.
ToStringReturns a readable string describing this reference.

Operators

Operator

Description

TableEntryReferenceConverts a key id into an id-based entry reference.

Enums

Enum

Description

TableEntryReference.TypeThe way a table entry reference identifies its entry.