Class TrackedRectTransform
Tracks and applies variant changes to a RectTransform.
Implements
Inherited Members
Namespace: UnityEngine.Localization.PropertyVariants.TrackedObjects
Assembly: Unity.Localization.dll
Syntax
[Serializable]
[DisplayName("Rect Transform", null)]
[CustomTrackedObject(typeof(RectTransform), false)]
public class TrackedRectTransform : TrackedTransform, ISerializationCallbackReceiver
Examples
This shows how to configure a GameObjectLocalizer to apply changes to a RectTransform for the x, y and width properties. This can be useful when you need to make adjustments due to changes in text length for a particular Locale.
public class SetupRectTransform : MonoBehaviour
{
void Start()
{
var localizer = gameObject.AddComponent<GameObjectLocalizer>();
// Gets the Tracked text or creates a new tracker
var trackedText = localizer.GetTrackedObject<TrackedRectTransform>(transform);
// Gets the Property Variant for the x, y and width
var xPos = trackedText.GetTrackedProperty<FloatTrackedProperty>("m_AnchoredPosition.x");
var yPos = trackedText.GetTrackedProperty<FloatTrackedProperty>("m_AnchoredPosition.y");
var width = trackedText.GetTrackedProperty<FloatTrackedProperty>("m_SizeDelta.x");
xPos.SetValue(LocalizationSettings.ProjectLocale.Identifier, 0); // Default is 0
xPos.SetValue("ja", 5); // Override for Japanese
yPos.SetValue(LocalizationSettings.ProjectLocale.Identifier, 10); // Default is 10
yPos.SetValue("fr", 5); // Override for French
width.SetValue(LocalizationSettings.ProjectLocale.Identifier, 100); // Default is 100
width.SetValue("ja", 50); // Japanese requires less space
width.SetValue("fr", 150); // French requires more space
// Force an Update
localizer.ApplyLocaleVariant(LocalizationSettings.SelectedLocale);
}
}
Methods
Name | Description |
---|---|
AddPropertyHandlers(Dictionary<string, Action<float>>) | |
ApplyLocale(Locale, Locale) | Apply the TrackedProperties for |