Ejemplo n.º 1
0
 void OrderHorizontal()
 {
     if (Enity != null)
     {
         float ps = Enity.SizeDelta.x;
         float sx = ps * -0.5f;
         if (FixedSizeRatio > 0)
         {
             ps *= FixedSizeRatio;
         }
         var   c  = Enity.childCount;
         float ox = ItemOffset;
         for (int i = 0; i < c; i++)
         {
             var   son = Enity.GetChild(i);
             float w   = 0;
             float p   = 0.5f;
             if (son != null)
             {
                 if (FixedSize)
                 {
                     w  = ps;
                     ox = ItemOffset * w;
                 }
                 else
                 {
                     w = son.SizeDelta.x;
                 }
                 p = son.Pivot.x;
             }
             float os = sx - w * -p + ox;
             son.localPosition = new Vector3(os, 0, 0);
             son.localScale    = Vector3.one;
             sx += w + spacing;
         }
     }
 }
Ejemplo n.º 2
0
 void OrderVertical()
 {
     if (Enity != null)
     {
         float ps = Enity.SizeDelta.y;
         float sy = ps * (1 - Enity.Pivot.y);
         if (FixedSizeRatio > 0)
         {
             ps *= FixedSizeRatio;
         }
         var   c  = Enity.childCount;
         float oy = ItemOffset;
         for (int i = 0; i < c; i++)
         {
             var   son = Enity.GetChild(i);
             float h   = 0;
             float p   = 0.5f;
             if (son != null)
             {
                 if (FixedSize)
                 {
                     h  = ps;
                     oy = h * ItemOffset;
                 }
                 else
                 {
                     h = son.SizeDelta.y;
                 }
                 p = son.Pivot.y;
             }
             float os = sy + h * (p - 1) - oy;
             son.localPosition = new Vector3(0, os, 0);
             son.localScale    = Vector3.one;
             sy -= h + spacing;
         }
     }
 }