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

LocalizedString.GetLocalizedStringAsync

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<string> GetLocalizedStringAsync(params Object[] args);

Parameters

Parameter Description
args Optional arguments that Smart String placeholders format against.

Returns

Awaitable<string> An awaitable that produces the formatted localized string, or an empty string when the reference is empty.

Description

Resolves the localized string asynchronously, formatting it with the given arguments.

Loads the table through the ResourceDatabase provider chain if needed, formats Smart String placeholders against the supplied arguments and LocalizedString.LocalVariables, and returns an empty string when the reference is empty. When LocalizationSettings.PreferredLoading is LoadingPreference.Synchronous, it resolves synchronously when the value is available and otherwise falls back to this asynchronous load.

<para>Resolve a string and format it with an argument.</para>

using Unity.Localization;
using UnityEngine;

namespace Unity.Localization.Samples { public class LocalizedStringFormatAsyncExample { public async Awaitable Resolve() { var localizedString = new LocalizedString(); localizedString.SetReference("My Strings", "GREETING"); string playerName = "Sam"; string text = await localizedString.GetLocalizedStringAsync(playerName); Debug.Log(text); } } }