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
- Type: Struct
- Namespace: Unity.Localization
- Assembly: UnityEngine.LocalizationRuntimeModule
- Implements: IEquatable<TableEntryReference>
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 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.
trueCreate 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 |
|---|---|
| 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. |
Methods
Method | Description |
|---|---|
| Equals | Checks whether this reference equals another object. |
| 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 a key id into an id-based entry reference. |
Enums
Enum | Description |
|---|---|
| TableEntryReference.Type | The way a table entry reference identifies its entry. |