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

CommandLineLocaleSelector

class in Unity.Localization


Implements interfaces:IStartupLocaleSelector

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

Description

Selects the locale from a command line argument, such as -language=fr.

On startup this selector scans the command line for the prefix set by CommandLineLocaleSelector.CommandLineArgument (-language= by default) and selects the locale whose LocaleIdentifier matches the value that follows, for example -language=fr. If the argument is absent or no available locale matches, CommandLineLocaleSelector.GetStartupLocale returns null and the next selector in LocalizationSettings.StartupSelectors runs. This selector is part of the default selector chain, ahead of SystemLocaleSelector.

Additional resources: IStartupLocaleSelector, LocalizationSettings

<para>Reads the locale from the command line when the player starts.</para>

using Unity.Localization;

namespace Unity.Localization.Samples { public class CommandLineLocaleSelectorExample { // Launch the player with: MyGame.exe -language=fr public Locale Run() { var selector = new CommandLineLocaleSelector(); Locale locale = selector.GetStartupLocale(LocalizationSettings.Instance); return locale; } } }

Properties

Property Description
CommandLineArgument The command line argument prefix used to assign the locale.