UnityEngine.GUILayoutGroup.SetVertical C# (CSharp) Method

SetVertical() public method

public SetVertical ( float y, float height ) : void
y float
height float
return void
        public override void SetVertical(float y, float height)
        {
            base.SetVertical(y, height);
            if (this.entries.Count != 0)
            {
                RectOffset padding = base.style.padding;
                if (this.resetCoords)
                {
                    y = 0f;
                }
                if (this.isVertical)
                {
                    if (base.style != GUIStyle.none)
                    {
                        float top = padding.top;
                        float bottom = padding.bottom;
                        if (this.entries.Count != 0)
                        {
                            top = Mathf.Max(top, (float) this.entries[0].margin.top);
                            bottom = Mathf.Max(bottom, (float) this.entries[this.entries.Count - 1].margin.bottom);
                        }
                        y += top;
                        height -= bottom + top;
                    }
                    float num3 = height - (this.spacing * (this.entries.Count - 1));
                    float t = 0f;
                    if (this.m_ChildMinHeight != this.m_ChildMaxHeight)
                    {
                        t = Mathf.Clamp((float) ((num3 - this.m_ChildMinHeight) / (this.m_ChildMaxHeight - this.m_ChildMinHeight)), (float) 0f, (float) 1f);
                    }
                    float num5 = 0f;
                    if ((num3 > this.m_ChildMaxHeight) && (this.m_StretchableCountY > 0))
                    {
                        num5 = (num3 - this.m_ChildMaxHeight) / ((float) this.m_StretchableCountY);
                    }
                    int num6 = 0;
                    bool flag = true;
                    foreach (GUILayoutEntry entry in this.entries)
                    {
                        float f = Mathf.Lerp(entry.minHeight, entry.maxHeight, t) + (num5 * entry.stretchHeight);
                        if (entry.style != GUILayoutUtility.spaceStyle)
                        {
                            int num8 = entry.margin.top;
                            if (flag)
                            {
                                num8 = 0;
                                flag = false;
                            }
                            int num9 = (num6 <= num8) ? num8 : num6;
                            y += num9;
                            num6 = entry.margin.bottom;
                        }
                        entry.SetVertical(Mathf.Round(y), Mathf.Round(f));
                        y += f + this.spacing;
                    }
                }
                else if (base.style != GUIStyle.none)
                {
                    foreach (GUILayoutEntry entry2 in this.entries)
                    {
                        float num10 = Mathf.Max(entry2.margin.top, padding.top);
                        float num11 = y + num10;
                        float num12 = (height - Mathf.Max(entry2.margin.bottom, padding.bottom)) - num10;
                        if (entry2.stretchHeight != 0)
                        {
                            entry2.SetVertical(num11, num12);
                        }
                        else
                        {
                            entry2.SetVertical(num11, Mathf.Clamp(num12, entry2.minHeight, entry2.maxHeight));
                        }
                    }
                }
                else
                {
                    float num13 = y - this.margin.top;
                    float num14 = height + this.margin.vertical;
                    foreach (GUILayoutEntry entry3 in this.entries)
                    {
                        if (entry3.stretchHeight != 0)
                        {
                            entry3.SetVertical(num13 + entry3.margin.top, num14 - entry3.margin.vertical);
                        }
                        else
                        {
                            entry3.SetVertical(num13 + entry3.margin.top, Mathf.Clamp(num14 - entry3.margin.vertical, entry3.minHeight, entry3.maxHeight));
                        }
                    }
                }
            }
        }

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::SetVertical