GetTableAsync(TableReference, Locale, CancellationToken)
Loads the resource table for a table reference in a locale through the provider chain.
Read time 1 minuteLast updated 19 days ago
Definition
- Type: Method
- Namespace: Unity.Localization
- Assembly: UnityEngine.LocalizationRuntimeModule
public Awaitable<ResourceTable> GetTableAsync(TableReference tableRef, Locale locale = null, CancellationToken cancellationToken = default)
Parameters
The reference to the table collection to load.
The locale to load the table for; null uses the selected locale.
The token that cancels the load operation.
Returns
Type | Description |
|---|---|
| Awaitable<ResourceTable> | The loaded resource table, or null when no table matches the reference in the locale. |
Remarks
The table loads asynchronously through the AssetProvider chain and is cached per locale, so repeated calls for the same table and locale reuse the loaded instance. Call this when you need the whole table, for example to enumerate its entries; to resolve a single value prefer ResourceDatabase.GetLocalizedStringAsync or ResourceDatabase.GetLocalizedAssetAsync. If the settings have not initialized yet, the first call triggers LocalizationSettings.InitializeAsync.
Loads a table and reports the locale it was loaded for.
Examples
using Unity.Localization;using UnityEngine;namespace Unity.Localization.Samples{ public class GetTableAsyncExample : MonoBehaviour { async void Start() { var database = LocalizationSettings.ResourceDatabase; ResourceTable table = await database.GetTableAsync("UI Text"); if (table != null) Debug.Log($"Loaded table for {LocalizationSettings.SelectedLocale?.Code}"); } }}