GetLocalizedAsset<TObject>(TableReference, TableEntryReference, Locale)
Resolves a localized asset synchronously from a synchronous provider and entry.
Read time 1 minuteLast updated 10 days ago
Definition
- Type: Method
- Namespace: Unity.Localization
- Assembly: UnityEngine.LocalizationRuntimeModule
GetLocalizedAsset<T>(TableReference, TableEntryReference, Locale)
public TObject GetLocalizedAsset<TObject>(TableReference tableRef, TableEntryReference entryRef, Locale locale = null) where TObject : Object
Parameters
The reference to the table collection that holds the entry.
The reference to the entry to resolve within the table.
The locale to resolve in; null uses the selected locale.
Returns
Type | Description |
|---|---|
| T | The resolved asset, or null when it cannot be resolved synchronously. |
Remarks
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 load. It returns null when the table or the asset can only be loaded asynchronously and is not already cached.
ResourcesReads a localized asset synchronously.
Examples
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"); } }}