UnityEngine.GUILayoutGroup.CalcHeight C# (CSharp) Method

CalcHeight() public method

public CalcHeight ( ) : void
return void
        public override void CalcHeight()
        {
            if (this.entries.Count == 0)
            {
                base.maxHeight = base.minHeight = base.style.padding.vertical;
            }
            else
            {
                int b = 0;
                int bottom = 0;
                this.m_ChildMinHeight = 0f;
                this.m_ChildMaxHeight = 0f;
                this.m_StretchableCountY = 0;
                if (this.isVertical)
                {
                    int a = 0;
                    bool flag = true;
                    foreach (GUILayoutEntry entry in this.entries)
                    {
                        entry.CalcHeight();
                        RectOffset margin = entry.margin;
                        if (entry.style != GUILayoutUtility.spaceStyle)
                        {
                            int num5;
                            if (!flag)
                            {
                                num5 = Mathf.Max(a, margin.top);
                            }
                            else
                            {
                                num5 = 0;
                                flag = false;
                            }
                            this.m_ChildMinHeight += (entry.minHeight + this.spacing) + num5;
                            this.m_ChildMaxHeight += (entry.maxHeight + this.spacing) + num5;
                            a = margin.bottom;
                            this.m_StretchableCountY += entry.stretchHeight;
                        }
                        else
                        {
                            this.m_ChildMinHeight += entry.minHeight;
                            this.m_ChildMaxHeight += entry.maxHeight;
                            this.m_StretchableCountY += entry.stretchHeight;
                        }
                    }
                    this.m_ChildMinHeight -= this.spacing;
                    this.m_ChildMaxHeight -= this.spacing;
                    if (this.entries.Count != 0)
                    {
                        b = this.entries[0].margin.top;
                        bottom = a;
                    }
                    else
                    {
                        bottom = b = 0;
                    }
                }
                else
                {
                    bool flag2 = true;
                    foreach (GUILayoutEntry entry2 in this.entries)
                    {
                        entry2.CalcHeight();
                        RectOffset offset2 = entry2.margin;
                        if (entry2.style != GUILayoutUtility.spaceStyle)
                        {
                            if (!flag2)
                            {
                                b = Mathf.Min(offset2.top, b);
                                bottom = Mathf.Min(offset2.bottom, bottom);
                            }
                            else
                            {
                                b = offset2.top;
                                bottom = offset2.bottom;
                                flag2 = false;
                            }
                            this.m_ChildMinHeight = Mathf.Max(entry2.minHeight, this.m_ChildMinHeight);
                            this.m_ChildMaxHeight = Mathf.Max(entry2.maxHeight, this.m_ChildMaxHeight);
                        }
                        this.m_StretchableCountY += entry2.stretchHeight;
                    }
                }
                float num6 = 0f;
                float num7 = 0f;
                if ((base.style != GUIStyle.none) || this.m_UserSpecifiedHeight)
                {
                    num6 = Mathf.Max(base.style.padding.top, b);
                    num7 = Mathf.Max(base.style.padding.bottom, bottom);
                }
                else
                {
                    this.m_Margin.top = b;
                    this.m_Margin.bottom = bottom;
                    num6 = num7 = 0f;
                }
                base.minHeight = Mathf.Max(base.minHeight, (this.m_ChildMinHeight + num6) + num7);
                if (base.maxHeight == 0f)
                {
                    base.stretchHeight += this.m_StretchableCountY + (!base.style.stretchHeight ? 0 : 1);
                    base.maxHeight = (this.m_ChildMaxHeight + num6) + num7;
                }
                else
                {
                    base.stretchHeight = 0;
                }
                base.maxHeight = Mathf.Max(base.maxHeight, base.minHeight);
                if (base.style.fixedHeight != 0f)
                {
                    base.maxHeight = base.minHeight = base.style.fixedHeight;
                    base.stretchHeight = 0;
                }
            }
        }

Usage Example

コード例 #1
0
        private static void LayoutSingleGroup(GUILayoutGroup i)
        {
            bool flag = !i.isWindow;

            if (flag)
            {
                float minWidth = i.minWidth;
                float maxWidth = i.maxWidth;
                i.CalcWidth();
                i.SetHorizontal(i.rect.x, Mathf.Clamp(i.maxWidth, minWidth, maxWidth));
                float minHeight = i.minHeight;
                float maxHeight = i.maxHeight;
                i.CalcHeight();
                i.SetVertical(i.rect.y, Mathf.Clamp(i.maxHeight, minHeight, maxHeight));
            }
            else
            {
                i.CalcWidth();
                Rect rect = GUILayoutUtility.Internal_GetWindowRect(i.windowID);
                i.SetHorizontal(rect.x, Mathf.Clamp(rect.width, i.minWidth, i.maxWidth));
                i.CalcHeight();
                i.SetVertical(rect.y, Mathf.Clamp(rect.height, i.minHeight, i.maxHeight));
                GUILayoutUtility.Internal_MoveWindow(i.windowID, i.rect);
            }
        }
All Usage Examples Of UnityEngine.GUILayoutGroup::CalcHeight