Utility functions for querying layout elements for their minimum, preferred, and flexible sizes.
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)); } } }
public static float GetLayoutProperty(RectTransform rect, Func <ILayoutElement, float> property, float defaultValue) { ILayoutElement layoutElement; return(LayoutUtility.GetLayoutProperty(rect, property, defaultValue, out layoutElement)); }
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))); }
public static float GetFlexibleHeight(RectTransform rect) { return(LayoutUtility.GetLayoutProperty(rect, (ILayoutElement e) => e.flexibleHeight, 0f)); }
public static float GetMinWidth(RectTransform rect) { return(LayoutUtility.GetLayoutProperty(rect, (ILayoutElement e) => e.minWidth, 0f)); }