Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


GetTable(TableReference, Locale)

Returns the resource table for a reference if it is already loaded, or null otherwise.
Read time 1 minuteLast updated 14 days ago

Definition

  • Type: Method
  • Namespace: Unity.Localization
  • Assembly: UnityEngine.LocalizationRuntimeModule
public ResourceTable GetTable(TableReference tableRef, Locale locale = null)

Parameters

The reference to the table collection to look up.

locale

The locale to look up; null uses the selected locale.

Returns

Type

Description

ResourceTableThe resource table for the reference in the locale, or null when it cannot be resolved synchronously.

Remarks

This is the synchronous companion to ResourceDatabase.GetTableAsync. It returns a cached table, otherwise it resolves the table through any provider in the chain that implements ISynchronousAssetProvider, such as direct references or a
Resources
load. A table that only a purely asynchronous provider can supply returns null until ResourceDatabase.GetTableAsync loads it. Use it on the main thread when you cannot await.
Reads a table if it is loaded, otherwise loads it asynchronously.

Examples

using Unity.Localization;using UnityEngine;namespace Unity.Localization.Samples{ public class GetTableSyncExample : MonoBehaviour { async void Start() { var database = LocalizationSettings.ResourceDatabase; ResourceTable table = database.GetTable("UI Text"); if (table == null) table = await database.GetTableAsync("UI Text"); Debug.Log(table != null ? "loaded" : "missing"); } }}