docs.unity3d.com
    Show / Hide Table of Contents

    Class TrackedRectTransform

    Tracks and applies variant changes to a RectTransform.

    Inheritance
    Object
    TrackedObject
    TrackedTransform
    TrackedRectTransform
    Inherited Members
    TrackedTransform.CanTrackProperty(String)
    TrackedObject.Target
    TrackedObject.TrackedProperties
    TrackedObject.AddTrackedProperty<T>(String)
    TrackedObject.AddTrackedProperty(ITrackedProperty)
    TrackedObject.RemoveTrackedProperty(ITrackedProperty)
    TrackedObject.GetTrackedProperty<T>(String, Boolean)
    TrackedObject.GetTrackedProperty(String)
    TrackedObject.CreateCustomTrackedProperty(String)
    TrackedObject.PostApplyTrackedProperties()
    Namespace: UnityEngine.Localization.PropertyVariants.TrackedObjects
    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

    AddPropertyHandlers(Dictionary<String, Action<Single>>)

    Declaration
    protected override void AddPropertyHandlers(Dictionary<string, Action<float>> handlers)
    Parameters
    Type Name Description
    Dictionary<String, Action<Single>> handlers
    Overrides
    TrackedTransform.AddPropertyHandlers(Dictionary<String, Action<Single>>)

    ApplyLocale(Locale, Locale)

    Declaration
    public override AsyncOperationHandle ApplyLocale(Locale variantLocale, Locale defaultLocale)
    Parameters
    Type Name Description
    Locale variantLocale
    Locale defaultLocale
    Returns
    Type Description
    AsyncOperationHandle
    Overrides
    TrackedTransform.ApplyLocale(Locale, Locale)
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023