LanguageRadioButtonGroup
A radio button group that lets the player pick a language.
Read time 9 minutesLast updated 11 days ago
Definition
- Type: Class
- Namespace: Unity.Localization.UI
- Assembly: UnityEngine.LocalizationRuntimeModule
- Inherits from: RadioButtonGroup
- Implements: IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, ICustomStyle, IBindable, IMixedValueSupport, INotifyValueChanged<int>
[UxmlElement]public class LanguageRadioButtonGroup : RadioButtonGroup, IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, ICustomStyle, IBindable, IMixedValueSupport, INotifyValueChanged<int>
Remarks
This is the LanguageDropdown as a list, for a settings screen that shows every language at once. It fills itself from LocalizationSettings.AvailableLocales and writes the chosen locale to LocalizationSettings.SelectedLocale, so it needs no setup code. Only the locales whose Locale.Enabled is true are offered, and the choices are replaced whenever the locales change, so setting them in UXML has no effect.
Additional Resources: LanguageDropdown, LocalizationSettings.SelectedLocale, LocalizationSettings.AvailableLocales
Adds a language radio button group to a panel from code.
Examples
using Unity.Localization.UI;using UnityEngine;using UnityEngine.UIElements;namespace Unity.Localization.Samples{ [RequireComponent(typeof(UIDocument))] public class LanguageRadioButtonGroupExample : MonoBehaviour { void OnEnable() { var group = new LanguageRadioButtonGroup("Language"); GetComponent<UIDocument>().rootVisualElement.Add(group); } }}
Constructors
Constructor | Description |
|---|---|
| LanguageRadioButtonGroup() | Creates a language radio button group with no label. |
| LanguageRadioButtonGroup(System.String) | Creates a language radio button group with a label above it. |