UnityEngine.GUILayoutEntry.CalcWidth C# (CSharp) Method

CalcWidth() public method

public CalcWidth ( ) : void
return void
        public virtual void CalcWidth()
        {
        }

Usage Example

コード例 #1
0
 public override void CalcWidth()
 {
     if (this.entries.Count == 0)
     {
         this.maxWidth = this.minWidth = (float)this.style.padding.horizontal;
     }
     else
     {
         int b1 = 0;
         int b2 = 0;
         this.m_ChildMinWidth     = 0.0f;
         this.m_ChildMaxWidth     = 0.0f;
         this.m_StretchableCountX = 0;
         bool flag = true;
         if (this.isVertical)
         {
             using (List <GUILayoutEntry> .Enumerator enumerator = this.entries.GetEnumerator())
             {
                 while (enumerator.MoveNext())
                 {
                     GUILayoutEntry current = enumerator.Current;
                     current.CalcWidth();
                     RectOffset margin = current.margin;
                     if (current.style != GUILayoutUtility.spaceStyle)
                     {
                         if (!flag)
                         {
                             b1 = Mathf.Min(margin.left, b1);
                             b2 = Mathf.Min(margin.right, b2);
                         }
                         else
                         {
                             b1   = margin.left;
                             b2   = margin.right;
                             flag = false;
                         }
                         this.m_ChildMinWidth = Mathf.Max(current.minWidth + (float)margin.horizontal, this.m_ChildMinWidth);
                         this.m_ChildMaxWidth = Mathf.Max(current.maxWidth + (float)margin.horizontal, this.m_ChildMaxWidth);
                     }
                     this.m_StretchableCountX += current.stretchWidth;
                 }
             }
             this.m_ChildMinWidth -= (float)(b1 + b2);
             this.m_ChildMaxWidth -= (float)(b1 + b2);
         }
         else
         {
             int num1 = 0;
             using (List <GUILayoutEntry> .Enumerator enumerator = this.entries.GetEnumerator())
             {
                 while (enumerator.MoveNext())
                 {
                     GUILayoutEntry current = enumerator.Current;
                     current.CalcWidth();
                     RectOffset margin = current.margin;
                     if (current.style != GUILayoutUtility.spaceStyle)
                     {
                         int num2;
                         if (!flag)
                         {
                             num2 = num1 <= margin.left ? margin.left : num1;
                         }
                         else
                         {
                             num2 = 0;
                             flag = false;
                         }
                         this.m_ChildMinWidth += current.minWidth + this.spacing + (float)num2;
                         this.m_ChildMaxWidth += current.maxWidth + this.spacing + (float)num2;
                         num1 = margin.right;
                         this.m_StretchableCountX += current.stretchWidth;
                     }
                     else
                     {
                         this.m_ChildMinWidth     += current.minWidth;
                         this.m_ChildMaxWidth     += current.maxWidth;
                         this.m_StretchableCountX += current.stretchWidth;
                     }
                 }
             }
             this.m_ChildMinWidth -= this.spacing;
             this.m_ChildMaxWidth -= this.spacing;
             if (this.entries.Count != 0)
             {
                 b1 = this.entries[0].margin.left;
                 b2 = num1;
             }
             else
             {
                 b1 = b2 = 0;
             }
         }
         float num3;
         float num4;
         if (this.style != GUIStyle.none || this.m_UserSpecifiedWidth)
         {
             num3 = (float)Mathf.Max(this.style.padding.left, b1);
             num4 = (float)Mathf.Max(this.style.padding.right, b2);
         }
         else
         {
             this.m_Margin.left  = b1;
             this.m_Margin.right = b2;
             num3 = num4 = 0.0f;
         }
         this.minWidth = Mathf.Max(this.minWidth, this.m_ChildMinWidth + num3 + num4);
         if ((double)this.maxWidth == 0.0)
         {
             this.stretchWidth += this.m_StretchableCountX + (!this.style.stretchWidth ? 0 : 1);
             this.maxWidth      = this.m_ChildMaxWidth + num3 + num4;
         }
         else
         {
             this.stretchWidth = 0;
         }
         this.maxWidth = Mathf.Max(this.maxWidth, this.minWidth);
         if ((double)this.style.fixedWidth == 0.0)
         {
             return;
         }
         this.maxWidth     = this.minWidth = this.style.fixedWidth;
         this.stretchWidth = 0;
     }
 }