docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class LayoutUtility

    Utility functions for querying layout elements for their minimum, preferred, and flexible sizes.

    Inheritance
    object
    LayoutUtility
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: UnityEngine.UI
    Assembly: UnityEngine.UI.dll
    Syntax
    public static class LayoutUtility

    Methods

    GetFlexibleHeight(RectTransform)

    Returns the flexible height of the layout element.

    Declaration
    public static float GetFlexibleHeight(RectTransform rect)
    Parameters
    Type Name Description
    RectTransform rect

    The RectTransform of the layout element to query.

    Returns
    Type Description
    float
    Remarks

    All components on the GameObject that implement the ILayoutElement are queried. The one with the highest priority which has a value for this setting is used. If multiple componets have this setting and have the same priority, the maximum value out of those is used.

    GetFlexibleSize(RectTransform, int)

    Returns the flexible size of the layout element.

    Declaration
    public static float GetFlexibleSize(RectTransform rect, int axis)
    Parameters
    Type Name Description
    RectTransform rect

    The RectTransform of the layout element to query.

    int axis

    The axis to query. This can be 0 or 1.

    Returns
    Type Description
    float
    Remarks

    All components on the GameObject that implement the ILayoutElement are queried. The one with the highest priority which has a value for this setting is used. If multiple componets have this setting and have the same priority, the maximum value out of those is used.

    GetFlexibleWidth(RectTransform)

    Returns the flexible width of the layout element.

    Declaration
    public static float GetFlexibleWidth(RectTransform rect)
    Parameters
    Type Name Description
    RectTransform rect

    The RectTransform of the layout element to query.

    Returns
    Type Description
    float
    Remarks

    All components on the GameObject that implement the ILayoutElement are queried. The one with the highest priority which has a value for this setting is used. If multiple componets have this setting and have the same priority, the maximum value out of those is used

    GetLayoutProperty(RectTransform, Func<ILayoutElement, float>, float)

    Gets a calculated layout property for the layout element with the given RectTransform.

    Declaration
    public static float GetLayoutProperty(RectTransform rect, Func<ILayoutElement, float> property, float defaultValue)
    Parameters
    Type Name Description
    RectTransform rect

    The RectTransform of the layout element to get a property for.

    Func<ILayoutElement, float> property

    The property to calculate.

    float defaultValue

    The default value to use if no component on the layout element supplies the given property

    Returns
    Type Description
    float

    The calculated value of the layout property.

    GetLayoutProperty(RectTransform, Func<ILayoutElement, float>, float, out ILayoutElement)

    Gets a calculated layout property for the layout element with the given RectTransform.

    Declaration
    public static float GetLayoutProperty(RectTransform rect, Func<ILayoutElement, float> property, float defaultValue, out ILayoutElement source)
    Parameters
    Type Name Description
    RectTransform rect

    The RectTransform of the layout element to get a property for.

    Func<ILayoutElement, float> property

    The property to calculate.

    float defaultValue

    The default value to use if no component on the layout element supplies the given property

    ILayoutElement source

    Optional out parameter to get the component that supplied the calculated value.

    Returns
    Type Description
    float

    The calculated value of the layout property.

    GetMinHeight(RectTransform)

    Returns the minimum height of the layout element.

    Declaration
    public static float GetMinHeight(RectTransform rect)
    Parameters
    Type Name Description
    RectTransform rect

    The RectTransform of the layout element to query.

    Returns
    Type Description
    float
    Remarks

    All components on the GameObject that implement the ILayoutElement are queried. The one with the highest priority which has a value for this setting is used. If multiple componets have this setting and have the same priority, the maximum value out of those is used.

    GetMinSize(RectTransform, int)

    Returns the minimum size of the layout element.

    Declaration
    public static float GetMinSize(RectTransform rect, int axis)
    Parameters
    Type Name Description
    RectTransform rect

    The RectTransform of the layout element to query.

    int axis

    The axis to query. This can be 0 or 1.

    Returns
    Type Description
    float
    Remarks

    All components on the GameObject that implement the ILayoutElement are queried. The one with the highest priority which has a value for this setting is used. If multiple componets have this setting and have the same priority, the maximum value out of those is used.

    GetMinWidth(RectTransform)

    Returns the minimum width of the layout element.

    Declaration
    public static float GetMinWidth(RectTransform rect)
    Parameters
    Type Name Description
    RectTransform rect

    The RectTransform of the layout element to query.

    Returns
    Type Description
    float
    Remarks

    All components on the GameObject that implement the ILayoutElement are queried. The one with the highest priority which has a value for this setting is used. If multiple componets have this setting and have the same priority, the maximum value out of those is used.

    GetPreferredHeight(RectTransform)

    Returns the preferred height of the layout element.

    Declaration
    public static float GetPreferredHeight(RectTransform rect)
    Parameters
    Type Name Description
    RectTransform rect

    The RectTransform of the layout element to query.

    Returns
    Type Description
    float
    Remarks

    All components on the GameObject that implement the ILayoutElement are queried. The one with the highest priority which has a value for this setting is used. If multiple componets have this setting and have the same priority, the maximum value out of those is used.

    GetPreferredSize(RectTransform, int)

    Returns the preferred size of the layout element.

    Declaration
    public static float GetPreferredSize(RectTransform rect, int axis)
    Parameters
    Type Name Description
    RectTransform rect

    The RectTransform of the layout element to query.

    int axis

    The axis to query. This can be 0 or 1.

    Returns
    Type Description
    float
    Remarks

    All components on the GameObject that implement the ILayoutElement are queried. The one with the highest priority which has a value for this setting is used. If multiple componets have this setting and have the same priority, the maximum value out of those is used.

    GetPreferredWidth(RectTransform)

    Returns the preferred width of the layout element.

    Declaration
    public static float GetPreferredWidth(RectTransform rect)
    Parameters
    Type Name Description
    RectTransform rect

    The RectTransform of the layout element to query.

    Returns
    Type Description
    float

    All components on the GameObject that implement the ILayoutElement are queried. The one with the highest priority which has a value for this setting is used. If multiple componets have this setting and have the same priority, the maximum value out of those is used.

    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)