Class TrackedUGuiDropdown
Uses JSON to apply variant data to UnityEngine.UI.Dropdown. Calls UnityEngine.UI.Dropdown.RefreshShownValue() on the target object after applying changes.
Implements
Inherited Members
Namespace: UnityEngine.Localization.PropertyVariants.TrackedObjects
Assembly: Unity.Localization.dll
Syntax
[Serializable]
[DisplayName("UI Dropdown", null)]
[CustomTrackedObject(typeof(Dropdown), true)]
public class TrackedUGuiDropdown : JsonSerializerTrackedObject, ISerializationCallbackReceiver
Examples
This shows how to configure a GameObjectLocalizer to apply changes to a Dropdown for the options values.
public class SetupDropdown : MonoBehaviour
{
public Dropdown dropdown;
void Start()
{
var localizer = gameObject.AddComponent<GameObjectLocalizer>();
// Gets the Tracked text or creates a new tracker
var trackedDropdown = localizer.GetTrackedObject<TrackedUGuiDropdown>(dropdown);
// Setup each option
for (int i = 0; i < dropdown.options.Count; ++i)
{
var optionText = trackedDropdown.GetTrackedProperty<LocalizedStringProperty>($"m_Options.m_Options.Array.data[{i}].m_Text");
optionText.LocalizedString.SetReference("My String Table", "My Option " + i);
}
// Force an Update
localizer.ApplyLocaleVariant(LocalizationSettings.SelectedLocale);
}
}
Methods
| Name | Description |
|---|---|
| PostApplyTrackedProperties() | Called when the variants have been applied to Target. |