Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


ResourceTable

A localization table that holds the translated values for one locale in a collection.
Read time 5 minutesLast updated 6 days ago

Definition

[HelpURL("localization/localization-tables")]public sealed class ResourceTable : ScriptableObject, ISerializationCallbackReceiver

Remarks

Each table targets a single locale (reported by ResourceTable.LocaleIdentifier) and shares its keys with every other locale table in the collection through one SharedTableData. Values are stored as polymorphic IResourceEntry objects (strings, assets, variants, or custom kinds) held through
[SerializeReference]
, so a single table type covers every entry kind. Look entries up by stable key id or by key text with the ResourceTable.GetEntry family, add plain strings with ResourceTable.AddStringEntry, and add fully-formed entries with ResourceTable.AddEntry. Tables belong to a collection: create one through the Resource Tables window, or with the ScriptableObject.CreateInstance method, assigning ResourceTable.SharedData before resolving keys by text.
Create a table, add a string, and read it back.

Examples

using Unity.Localization;using UnityEngine;namespace Unity.Localization.Samples{ public class ResourceTableOverviewExample { public void Run() { var shared = ScriptableObject.CreateInstance<SharedTableData>(); var table = ScriptableObject.CreateInstance<ResourceTable>(); table.SharedData = shared; table.LocaleIdentifier = "en"; table.AddStringEntry("Greeting", "Hello"); var entry = table.GetEntry<IStringEntry>("Greeting"); Debug.Log(entry.Value); // Hello } }}

Properties

Property

Description

EntriesThe entries this table holds for its locale.
LocaleIdentifierThe locale this table provides values for.
MetadataThe metadata attached to this table for its locale.
SharedDataThe shared key data for the collection this table belongs to.
TableCollectionNameThe name of the collection this table belongs to.

Methods

Method

Description

AddEntryAdds an entry, replacing any existing entry with the same key id.
AddStringEntryAdds or updates a plain string entry for a key.
AddStringVariantAdds or updates a variant value for a string key in this table.
GetEntryReturns the entry stored for a stable key id.
RemoveAllEntriesRemoves every entry from this table.
RemoveEntryRemoves the entry for a stable key id from this table.
RemoveVariantRemoves one variant value from a key's entry in this table.

Inheritance

Inherited Members

Operators

Operator

Description

operator ==Compares two object references to see if they refer to the same object.
boolDetermines whether the object exists.
operator !=Compares if two objects refer to a different object.