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

ResourceDatabase.GetLocalizedAsset

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 TObject GetLocalizedAsset(TableReference tableRef, TableEntryReference entryRef, Locale locale);

Parameters

Parameter Description
tableRef The reference to the table collection that holds the entry.
entryRef The reference to the entry to resolve within the table.
locale The locale to resolve in; null uses the selected locale.

Returns

TObject The resolved asset, or null when it cannot be resolved synchronously.

Description

Resolves a localized asset synchronously from a synchronous provider and entry.

This is the synchronous companion to ResourceDatabase.GetLocalizedAssetAsync. It resolves the table through a provider that implements ISynchronousAssetProvider and loads the asset through an entry that implements ISynchronousAssetEntry, such as a direct reference or a Resources load. It returns null when the table or the asset can only be loaded asynchronously and is not already cached.

<para>Reads a localized asset synchronously.</para>

using Unity.Localization;
using UnityEngine;

namespace Unity.Localization.Samples { public class GetLocalizedAssetSyncExample : MonoBehaviour { void Start() { // Resolves immediately when the table and asset come from synchronous providers (direct references or Resources). Sprite flag = LocalizationSettings.ResourceDatabase.GetLocalizedAsset<Sprite>("UI Assets", "flag"); Debug.Log(flag != null ? flag.name : "no flag"); } } }