FlipLayoutAxes() public static method

Flips the horizontal and vertical axes of the RectTransform size and alignment, and optionally its children as well.

public static FlipLayoutAxes ( RectTransform rect, bool keepPositioning, bool recursive ) : void
rect RectTransform The RectTransform to flip.
keepPositioning bool Flips around the pivot if true. Flips within the parent rect if false.
recursive bool Flip the children as well?
return void
コード例 #1
0
 public static void FlipLayoutAxes(RectTransform rect, bool keepPositioning, bool recursive)
 {
     if (rect == null)
     {
         return;
     }
     if (recursive)
     {
         for (int i = 0; i < rect.childCount; i++)
         {
             RectTransform rectTransform = rect.GetChild(i) as RectTransform;
             if (rectTransform != null)
             {
                 RectTransformUtility.FlipLayoutAxes(rectTransform, false, true);
             }
         }
     }
     rect.pivot     = RectTransformUtility.GetTransposed(rect.pivot);
     rect.sizeDelta = RectTransformUtility.GetTransposed(rect.sizeDelta);
     if (keepPositioning)
     {
         return;
     }
     rect.anchoredPosition = RectTransformUtility.GetTransposed(rect.anchoredPosition);
     rect.anchorMin        = RectTransformUtility.GetTransposed(rect.anchorMin);
     rect.anchorMax        = RectTransformUtility.GetTransposed(rect.anchorMax);
 }
コード例 #2
0
 /// <summary>
 ///   <para>Flips the horizontal and vertical axes of the RectTransform size and alignment, 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>
 public static void FlipLayoutAxes(RectTransform rect, 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.FlipLayoutAxes(child, false, true);
             }
         }
     }
     rect.pivot     = RectTransformUtility.GetTransposed(rect.pivot);
     rect.sizeDelta = RectTransformUtility.GetTransposed(rect.sizeDelta);
     if (keepPositioning)
     {
         return;
     }
     rect.anchoredPosition = RectTransformUtility.GetTransposed(rect.anchoredPosition);
     rect.anchorMin        = RectTransformUtility.GetTransposed(rect.anchorMin);
     rect.anchorMax        = RectTransformUtility.GetTransposed(rect.anchorMax);
 }