FlipLayoutOnAxis() public static méthode

Flips the alignment of the RectTransform along the horizontal or vertical axis, and optionally its children as well.

public static FlipLayoutOnAxis ( RectTransform rect, int axis, bool keepPositioning, bool recursive ) : void
rect RectTransform The RectTransform to flip.
axis int The axis to flip along. 0 is horizontal and 1 is vertical.
keepPositioning bool Flips around the pivot if true. Flips within the parent rect if false.
recursive bool Flip the children as well?
Résultat void
 public static void FlipLayoutOnAxis(RectTransform rect, int axis, bool keepPositioning, bool recursive)
 {
     if (!(rect == null))
     {
         if (recursive)
         {
             for (int i = 0; i < rect.childCount; i++)
             {
                 RectTransform rectTransform = rect.GetChild(i) as RectTransform;
                 if (rectTransform != null)
                 {
                     RectTransformUtility.FlipLayoutOnAxis(rectTransform, axis, false, true);
                 }
             }
         }
         Vector2 pivot = rect.pivot;
         pivot[axis] = 1f - pivot[axis];
         rect.pivot  = pivot;
         if (!keepPositioning)
         {
             Vector2 anchoredPosition = rect.anchoredPosition;
             anchoredPosition[axis] = -anchoredPosition[axis];
             rect.anchoredPosition  = anchoredPosition;
             Vector2 anchorMin = rect.anchorMin;
             Vector2 anchorMax = rect.anchorMax;
             float   num       = anchorMin[axis];
             anchorMin[axis] = 1f - anchorMax[axis];
             anchorMax[axis] = 1f - num;
             rect.anchorMin  = anchorMin;
             rect.anchorMax  = anchorMax;
         }
     }
 }
        /// <summary>
        ///   <para>Flips the alignment of the RectTransform along the horizontal or vertical axis, and optionally its children as well.</para>
        /// </summary>
        /// <param name="rect">The RectTransform to flip.</param>
        /// <param name="keepPositioning">Flips around the pivot if true. Flips within the parent rect if false.</param>
        /// <param name="recursive">Flip the children as well?</param>
        /// <param name="axis">The axis to flip along. 0 is horizontal and 1 is vertical.</param>
        public static void FlipLayoutOnAxis(RectTransform rect, int axis, bool keepPositioning, bool recursive)
        {
            if ((Object)rect == (Object)null)
            {
                return;
            }
            if (recursive)
            {
                for (int index = 0; index < rect.childCount; ++index)
                {
                    RectTransform child = rect.GetChild(index) as RectTransform;
                    if ((Object)child != (Object)null)
                    {
                        RectTransformUtility.FlipLayoutOnAxis(child, axis, false, true);
                    }
                }
            }
            Vector2 pivot = rect.pivot;

            pivot[axis] = 1f - pivot[axis];
            rect.pivot  = pivot;
            if (keepPositioning)
            {
                return;
            }
            Vector2 anchoredPosition = rect.anchoredPosition;

            anchoredPosition[axis] = -anchoredPosition[axis];
            rect.anchoredPosition  = anchoredPosition;
            Vector2 anchorMin = rect.anchorMin;
            Vector2 anchorMax = rect.anchorMax;
            float   num       = anchorMin[axis];

            anchorMin[axis] = 1f - anchorMax[axis];
            anchorMax[axis] = 1f - num;
            rect.anchorMin  = anchorMin;
            rect.anchorMax  = anchorMax;
        }