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

LocalizedAsset<T0>.GetLocalizedAssetAsync

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<TObject> GetLocalizedAssetAsync();

Returns

Awaitable<TObject> An awaitable that produces the loaded asset, or null when it cannot be resolved.

Description

Loads the localized asset asynchronously through the resource database.

Resolves the asset as TObject through the ResourceDatabase provider chain, loading the table if needed. The result is null when the reference is empty, no resource database is configured, or the asset cannot be found. When LocalizationSettings.PreferredLoading is LoadingPreference.Synchronous and the asset is available synchronously, the asset resolves without an asynchronous load.

<para>Load a localized asset.</para>

using Unity.Localization;
using UnityEngine;

namespace Unity.Localization.Samples { public class LocalizedAssetLoadAsyncExample { public async Awaitable Load() { var localizedTexture = new LocalizedTexture(); localizedTexture.SetReference("My Assets", "ICON"); var texture = await localizedTexture.GetLocalizedAssetAsync(); if (texture != null) Debug.Log(texture.name); } } }