SetVertical() public method

public SetVertical ( float y, float height ) : void
y float
height float
return void
コード例 #1
0
        public override void SetVertical(float y, float height)
        {
            base.SetVertical(y, height);
            if (this.entries.Count == 0)
            {
                return;
            }
            RectOffset padding = this.style.padding;

            if (this.resetCoords)
            {
                y = 0.0f;
            }
            if (this.isVertical)
            {
                if (this.style != GUIStyle.none)
                {
                    float a1 = (float)padding.top;
                    float a2 = (float)padding.bottom;
                    if (this.entries.Count != 0)
                    {
                        a1 = Mathf.Max(a1, (float)this.entries[0].margin.top);
                        a2 = Mathf.Max(a2, (float)this.entries[this.entries.Count - 1].margin.bottom);
                    }
                    y      += a1;
                    height -= a2 + a1;
                }
                float num1 = height - this.spacing * (float)(this.entries.Count - 1);
                float t    = 0.0f;
                if ((double)this.m_ChildMinHeight != (double)this.m_ChildMaxHeight)
                {
                    t = Mathf.Clamp((float)(((double)num1 - (double)this.m_ChildMinHeight) / ((double)this.m_ChildMaxHeight - (double)this.m_ChildMinHeight)), 0.0f, 1f);
                }
                float num2 = 0.0f;
                if ((double)num1 > (double)this.m_ChildMaxHeight && this.m_StretchableCountY > 0)
                {
                    num2 = (num1 - this.m_ChildMaxHeight) / (float)this.m_StretchableCountY;
                }
                int  num3 = 0;
                bool flag = true;
                using (List <GUILayoutEntry> .Enumerator enumerator = this.entries.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        GUILayoutEntry current = enumerator.Current;
                        float          f       = Mathf.Lerp(current.minHeight, current.maxHeight, t) + num2 * (float)current.stretchHeight;
                        if (current.style != GUILayoutUtility.spaceStyle)
                        {
                            int num4 = current.margin.top;
                            if (flag)
                            {
                                num4 = 0;
                                flag = false;
                            }
                            int num5 = num3 <= num4 ? num4 : num3;
                            y   += (float)num5;
                            num3 = current.margin.bottom;
                        }
                        current.SetVertical(Mathf.Round(y), Mathf.Round(f));
                        y += f + this.spacing;
                    }
                }
            }
            else if (this.style != GUIStyle.none)
            {
                using (List <GUILayoutEntry> .Enumerator enumerator = this.entries.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        GUILayoutEntry current = enumerator.Current;
                        float          num     = (float)Mathf.Max(current.margin.top, padding.top);
                        float          y1      = y + num;
                        float          height1 = height - (float)Mathf.Max(current.margin.bottom, padding.bottom) - num;
                        if (current.stretchHeight != 0)
                        {
                            current.SetVertical(y1, height1);
                        }
                        else
                        {
                            current.SetVertical(y1, Mathf.Clamp(height1, current.minHeight, current.maxHeight));
                        }
                    }
                }
            }
            else
            {
                float num1 = y - (float)this.margin.top;
                float num2 = height + (float)this.margin.vertical;
                using (List <GUILayoutEntry> .Enumerator enumerator = this.entries.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        GUILayoutEntry current = enumerator.Current;
                        if (current.stretchHeight != 0)
                        {
                            current.SetVertical(num1 + (float)current.margin.top, num2 - (float)current.margin.vertical);
                        }
                        else
                        {
                            current.SetVertical(num1 + (float)current.margin.top, Mathf.Clamp(num2 - (float)current.margin.vertical, current.minHeight, current.maxHeight));
                        }
                    }
                }
            }
        }