Change Language#
Game Creator / Dialogue / Localization / Change Language
Description#
Changes the current Language of the Dialogue system
Note
Attempting to change the language ID to an invalid one will result in an error thrown
Parameters#
| Name | Description |
|---|---|
| Locale ID | The identifier of the Locale that matches the ones from the Settings |
Code#
using System;
using UnityEngine;
using VisualScript.Icons;
using VisualScript.Runtime;
namespace GameCreator.Runtime.Dialogue
{
[Title("Change Language")]
[Image(typeof(IconLocalization), ColorTheme.Type.Blue)]
[Description("Changes the current Language of the Dialogue system")]
[Category("Game Creator/Dialogue/Localization/Change Language")]
[Parameter("Locale ID", "The identifier of the Locale that matches the ones from the Settings")]
[Keywords("Locale", "Language", "Localize", "Localization", "Idiom")]
[Note("Attempting to change the language ID to an invalid one will result in an error thrown")]
[Serializable]
public class InstructionDialogueChangeLanguage : Instruction
{
[SerializeField] private GetString m_Locale = new GetString("en");
protected override string GetTitle(GameObject source) => $"Language = {this.m_Locale}";
protected override Awaitable Run(Args args)
{
string locale = this.m_Locale.Get(args);
LocalizationManager.SetCurrentId(locale);
return Done;
}
}
}