예제 #1
0
        /// <summary>
        /// Is target height under layout group or fitter control?
        /// </summary>
        /// <param name="target">Target.</param>
        /// <returns>true if target height under layout group or fitter control; otherwise false.</returns>
        public static bool IsHeightControlled(RectTransform target)
        {
            var ignorer = Compatibility.GetComponent <ILayoutIgnorer>(target);

            if ((ignorer != null) && ignorer.ignoreLayout)
            {
                return(false);
            }

            var fitter = target.GetComponent <ContentSizeFitter>();

            if ((fitter != null) && (fitter.verticalFit != ContentSizeFitter.FitMode.Unconstrained))
            {
                return(true);
            }

            var parent = target.transform.parent as RectTransform;

            if (parent != null)
            {
                var layout_group = parent.GetComponent <LayoutGroup>();
                if (layout_group == null)
                {
                    return(false);
                }

                var g_layout_group = layout_group as GridLayoutGroup;
                if ((g_layout_group != null) && g_layout_group.enabled)
                {
                    return(true);
                }

                var hv_layout_group = layout_group as HorizontalOrVerticalLayoutGroup;
                if ((hv_layout_group != null) && hv_layout_group.enabled)
                {
                    return(Compatibility.GetLayoutChildControlHeight(hv_layout_group));
                }

                var e_layout_group = layout_group as EasyLayout;
                if ((e_layout_group != null) && e_layout_group.enabled)
                {
                    return(e_layout_group.ChildrenHeight != ChildrenSize.DoNothing);
                }
            }

            return(false);
        }