CommandLineLocaleSelector
Selects the locale from a command line argument, such as -language=fr.
Read time 1 minuteLast updated 13 days ago
Definition
- Type: Class
- Namespace: Unity.Localization
- Assembly: UnityEngine.LocalizationRuntimeModule
- Implements: IStartupLocaleSelector
public class CommandLineLocaleSelector : IStartupLocaleSelector
Remarks
On startup this selector scans the command line for the prefix set by CommandLineLocaleSelector.CommandLineArgument ( by default) and selects the locale whose LocaleIdentifier matches the value that follows, for example . If the argument is absent or no available locale matches, GetStartupLocale returns null and the next selector in LocalizationSettings.StartupSelectors runs. This selector is part of the default selector chain, ahead of SystemLocaleSelector.
-language=-language=frAdditional Resources: IStartupLocaleSelector, LocalizationSettings
Reads the locale from the command line when the player starts.
Examples
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. |