Class TrackedTmpDropdown
Uses JSON to apply variant data to TMPro.TMP_Dropdown. Calls TMPro.TMP_Dropdown.RefreshShownValue() on the target object after applying changes.
Implements
Inherited Members
Namespace: UnityEngine.Localization.PropertyVariants.TrackedObjects
Assembly: Unity.Localization.dll
Syntax
[Serializable]
[DisplayName("TMP Dropdown", null)]
[CustomTrackedObject(typeof(TMP_Dropdown), true)]
public class TrackedTmpDropdown : JsonSerializerTrackedObject, ISerializationCallbackReceiver
Examples
This shows how to configure a GameObjectLocalizer to apply changes to a TMP_Dropdown for the options values.
public class SetupTmpDropdown : MonoBehaviour
{
public TMP_Dropdown dropdown;
void Start()
{
var localizer = gameObject.AddComponent<GameObjectLocalizer>();
// Gets the Tracked text or creates a new tracker
var trackedDropdown = localizer.GetTrackedObject<TrackedTmpDropdown>(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. |