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

ResourceDatabase.GetTableAsync

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

Declaration

public Awaitable<ResourceTable> GetTableAsync(TableReference tableRef, Locale locale, CancellationToken cancellationToken);

Parameters

Parameter Description
tableRef The reference to the table collection to load.
locale The locale to load the table for; null uses the selected locale.
cancellationToken The token that cancels the load operation.

Returns

Awaitable<ResourceTable> The loaded resource table, or null when no table matches the reference in the locale.

Description

Loads the resource table for a table reference in a locale through the provider chain.

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.

<para>Loads a table and reports the locale it was loaded for.</para>

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}"); } } }