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

コード例 #1
0
        private void HandleSelfFittingAlongAxis(int axis)
        {
            FitMode mode = (axis != 0) ? this.verticalFit : this.horizontalFit;

            if (mode != FitMode.Unconstrained)
            {
                this.m_Tracker.Add(this, this.rectTransform, (axis != 0) ? DrivenTransformProperties.SizeDeltaY : DrivenTransformProperties.SizeDeltaX);
                if (mode == FitMode.MinSize)
                {
                    this.rectTransform.SetSizeWithCurrentAnchors((RectTransform.Axis)axis, LayoutUtility.GetMinSize(this.m_Rect, axis));
                }
                else
                {
                    this.rectTransform.SetSizeWithCurrentAnchors((RectTransform.Axis)axis, LayoutUtility.GetPreferredSize(this.m_Rect, axis));
                }
            }
        }
コード例 #2
0
        public static float GetLayoutProperty(RectTransform rect, Func <ILayoutElement, float> property, float defaultValue)
        {
            ILayoutElement layoutElement;

            return(LayoutUtility.GetLayoutProperty(rect, property, defaultValue, out layoutElement));
        }
コード例 #3
0
 public static float GetPreferredHeight(RectTransform rect)
 {
     return(Mathf.Max(LayoutUtility.GetLayoutProperty(rect, (ILayoutElement e) => e.minHeight, 0f), LayoutUtility.GetLayoutProperty(rect, (ILayoutElement e) => e.preferredHeight, 0f)));
 }
コード例 #4
0
 public static float GetFlexibleHeight(RectTransform rect)
 {
     return(LayoutUtility.GetLayoutProperty(rect, (ILayoutElement e) => e.flexibleHeight, 0f));
 }
コード例 #5
0
 public static float GetMinWidth(RectTransform rect)
 {
     return(LayoutUtility.GetLayoutProperty(rect, (ILayoutElement e) => e.minWidth, 0f));
 }