Esempio n. 1
0
 public void Add(Side side, RectTransform content, CustomLayout caller = null)
 {
     if ((LayoutGroup is HorizontalLayoutGroup && (side == Side.Top || side == Side.Bottom)) || (LayoutGroup is VerticalLayoutGroup && (side == Side.Left || side == Side.Right)))
     {
         CustomLayout parentLayout = CheckParent();
         parentLayout.AddLayout(this, transform.GetSiblingIndex());
         int index;
         if (side == Side.Left || side == Side.Top)
         {
             index = transform.GetSiblingIndex();
         }
         else
         {
             index = transform.GetSiblingIndex() + 1;
         }
         parentLayout.Add(index, content);
     }
     else
     {
         if (ContentRectTransform.childCount > 0) // Content CustomLayout.
         {
             int index1, index2;
             if (side == Side.Left || side == Side.Top)
             {
                 index1 = 1;
                 index2 = 0;
             }
             else
             {
                 index1 = 0;
                 index2 = 1;
             }
             Add(index1, ContentRectTransform.GetChild(0).GetComponent <RectTransform>());
             Add(index2, content);
         }
         else // Intermediate CustomLayout.
         {
             int index = caller.transform.GetSiblingIndex();
             if (side == Side.Left || side == Side.Top)
             {
             }
             else
             {
                 index++;
             }
             Add(index, content);
         }
     }
 }