Tracks and applies variant changes to a RectTransform.
Inheritance
TrackedRectTransform
public class TrackedRectTransform : TrackedTransform
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
Declaration
protected override void AddPropertyHandlers(Dictionary<string, Action<float>> handlers)
Parameters
Type |
Name |
Description |
Dictionary<String, Action<Single>> |
handlers |
|
Overrides
Declaration
public override AsyncOperationHandle ApplyLocale(Locale variantLocale, Locale defaultLocale)
Parameters
Type |
Name |
Description |
Locale |
variantLocale |
|
Locale |
defaultLocale |
|
Returns
Type |
Description |
AsyncOperationHandle |
|
Overrides