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

ResourceDatabase.GetTable

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 ResourceTable GetTable(TableReference tableRef, Locale locale);

Parameters

Parameter Description
tableRef The reference to the table collection to look up.
locale The locale to look up; null uses the selected locale.

Returns

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

Description

Returns the resource table for a reference if it is already loaded, or null otherwise.

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.

<para>Reads a table if it is loaded, otherwise loads it asynchronously.</para>

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