コード例 #1
0
 public static void Align(this RectTransform rect, UGUITools.enLayoutAlign alignment, bool adjustPivot, Vector2 offset,
                          Vector2 size)
 {
     rect.SetAlignment(UGUITools.GetAlignedPivot(alignment), adjustPivot, offset, size);
 }
コード例 #2
0
        protected virtual void SetPivotAndAnchors(RectTransform rect, UGUITools.enLayoutAlign align)
        {
            if (IsExpandItem)
            {
                if (IsVertical)
                {
                    if (align == UGUITools.enLayoutAlign.BottomLeft || align == UGUITools.enLayoutAlign.BottomRight)
                    {
                        align = UGUITools.enLayoutAlign.Bottom;
                    }
                    else if (align == UGUITools.enLayoutAlign.TopLeft || align == UGUITools.enLayoutAlign.TopRight)
                    {
                        align = UGUITools.enLayoutAlign.Top;
                    }
                    else if (align == UGUITools.enLayoutAlign.Left || align == UGUITools.enLayoutAlign.Right)
                    {
                        align = UGUITools.enLayoutAlign.Center;
                    }
                }
                else
                {
                    if (align == UGUITools.enLayoutAlign.BottomLeft || align == UGUITools.enLayoutAlign.TopLeft)
                    {
                        align = UGUITools.enLayoutAlign.Left;
                    }
                    else if (align == UGUITools.enLayoutAlign.TopRight || align == UGUITools.enLayoutAlign.BottomRight)
                    {
                        align = UGUITools.enLayoutAlign.Right;
                    }
                    else if (align == UGUITools.enLayoutAlign.Top || align == UGUITools.enLayoutAlign.Bottom)
                    {
                        align = UGUITools.enLayoutAlign.Center;
                    }
                }
            }

            if (ScrollRect != null)
            {
                if (IsVertical)
                {
                    if (align == UGUITools.enLayoutAlign.BottomLeft || align == UGUITools.enLayoutAlign.Left ||
                        align == UGUITools.enLayoutAlign.TopLeft)
                    {
                        align = IsInverseDirection ? UGUITools.enLayoutAlign.BottomLeft : UGUITools.enLayoutAlign.TopLeft;
                    }
                    else if (align == UGUITools.enLayoutAlign.BottomRight || align == UGUITools.enLayoutAlign.Right ||
                             align == UGUITools.enLayoutAlign.TopRight)
                    {
                        align = IsInverseDirection ? UGUITools.enLayoutAlign.BottomRight : UGUITools.enLayoutAlign.TopRight;
                    }
                    else
                    {
                        align = IsInverseDirection ? UGUITools.enLayoutAlign.Bottom : UGUITools.enLayoutAlign.Top;
                    }
                }
                else
                {
                    if (align == UGUITools.enLayoutAlign.BottomLeft || align == UGUITools.enLayoutAlign.Bottom ||
                        align == UGUITools.enLayoutAlign.BottomRight)
                    {
                        align = IsInverseDirection ? UGUITools.enLayoutAlign.BottomRight : UGUITools.enLayoutAlign.BottomLeft;
                    }
                    else if (align == UGUITools.enLayoutAlign.TopLeft || align == UGUITools.enLayoutAlign.Top ||
                             align == UGUITools.enLayoutAlign.TopRight)
                    {
                        align = IsInverseDirection ? UGUITools.enLayoutAlign.TopRight : UGUITools.enLayoutAlign.TopLeft;
                    }
                    else
                    {
                        align = IsInverseDirection ? UGUITools.enLayoutAlign.Right : UGUITools.enLayoutAlign.Left;
                    }
                }
            }

            Vector2 pos = UGUITools.GetAlignedPivot(align);

            TemplateRect.pivot     = pos;
            TemplateRect.anchorMax = pos;
            TemplateRect.anchorMin = pos;
            AdjustItemAnchor(rect, false);
        }