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

TableReference

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 table collection, identified either by its name or by its collection GUID.

A table reference identifies a table collection without holding a direct object reference, which keeps it lightweight and serializable. It stores either a collection name or a collection GUID; TableReference.ReferenceType reports which form is in use, and TableReference.IsEmpty is true when neither is set. Assign one implicitly from a string to reference by name, or call TableReference.FromGuid to reference by GUID. Name references are convenient in code, while GUID references keep resolving after a collection is renamed. Pair a table reference with a TableEntryReference to address a single entry, and resolve either against a ResourceDatabase or a ResourceTable.

Additional resources: ResourceTable, ResourceDatabase, TableEntryReference, SharedTableData

<para>Create references by name and by GUID, then inspect how each identifies its collection.</para>

using Unity.Localization;
using UnityEngine;

namespace Unity.Localization.Samples { public class TableReferenceOverviewExample { public void Run() { TableReference byName = "UI Text"; // implicit conversion from string TableReference byGuid = TableReference.FromGuid("6f1e2c0a9b3d4e5f8a1b2c3d4e5f6a7b");

Debug.Log(byName.ReferenceType); // Name Debug.Log(byGuid.ReferenceType); // Guid Debug.Log(byName.IsEmpty); // False } } }

Properties

Property Description
IsEmpty Whether this reference points at nothing.
ReferenceType How this reference identifies its collection.
TableCollectionName The name of the referenced collection, or null when the reference is empty or GUID-based.
TableCollectionNameGuid The GUID of the referenced collection, or an empty GUID when the reference is empty or name-based.

Public Methods

Method Description
Equals Checks whether this reference identifies the same collection as another.
GetHashCode Computes a hash code for this reference.
ToString Returns a readable string describing this reference.

Static Methods

Method Description
FromGuid Creates a table reference that identifies a collection by its GUID.

Operators

Operator Description
TableReference Converts a collection name into a name-based table reference.