Ejemplo n.º 1
0
    protected virtual void RecalculateBound()
    {
        Vector2 new_pos = GNewUITools.GetAlignedPivot(NewAlign.Left);

        if (IsVertical)
        {
            new_pos = GNewUITools.GetAlignedPivot(NewAlign.Top);
        }
        RectTrans.pivot     = new_pos;
        RectTrans.anchorMax = new_pos;
        RectTrans.anchorMin = new_pos;

        _RealBound = PackBound(_ItemCount);
        if (_RealBound.z < 0)
        {
            _RealBound.z = RectTrans.rect.width;
        }
        if (_RealBound.w < 0)
        {
            _RealBound.w = RectTrans.rect.height;
        }

        Vector2 new_size = new Vector2(_RealBound.z, _RealBound.w);

        this.RectTrans.sizeDelta = GNewUITools.GetDeltaSize(RectTrans, new_size);
    }
Ejemplo n.º 2
0
    protected virtual void SetPivotAnchor(RectTransform rect, NewAlign align)
    {
        Vector2 new_pos = GNewUITools.GetAlignedPivot(align);

        rect.pivot = new_pos;

        rect.anchorMax = new_pos;
        rect.anchorMin = new_pos;
    }
Ejemplo n.º 3
0
    protected GDragablePageItem CreateItem()
    {
        GDragablePageItem page_item = null;

        page_item = _Pool.TakeOut();

        if (page_item == null)
        {
            RectTransform item = CUnityUtil.Instantiate(_CellItem) as RectTransform;
            item.SetParent(Trans, false);
            Vector2 new_pos = GNewUITools.GetAlignedPivot(NewAlign.Left);
            if (IsVertical)
            {
                new_pos = GNewUITools.GetAlignedPivot(NewAlign.Top);
            }
            item.pivot     = new_pos;
            item.anchorMax = new_pos;
            item.anchorMin = new_pos;

            GDragablePageItem item_com = item.GetComponent <GDragablePageItem>();
            if (item_com == null)
            {
                item_com = item.gameObject.AddComponent <GDragablePageItem>();
            }

            if (this._PageItemInitCallBack != null)
            {
                item_com.OnItemInit = OnInitPageItem;
            }

            if (this._ClickPageItemCallBack != null)
            {
                item_com.OnItemClick = OnClickPageItem;
            }

            if (_HasChildButton && this._ClickPageItemButtonCallBack != null)
            {
                item_com.OnItemClickButton = this.OnClickPageItemButton;
            }

            page_item = item_com;
        }

        GNewUITools.SetVisible(page_item.RectTrans, true);

        return(page_item);
    }
Ejemplo n.º 4
0
    //no-base call
    protected override void SetPivotAnchor(RectTransform rect, NewAlign align)
    {
        if (_IsExpandItem)
        {
            if (IsVertical)
            {
                if (align == NewAlign.BottomLeft || align == NewAlign.BottomRight)
                {
                    align = NewAlign.Bottom;
                }
                else if (align == NewAlign.TopLeft || align == NewAlign.TopRight)
                {
                    align = NewAlign.Top;
                }
                else if (align == NewAlign.Left || align == NewAlign.Right)
                {
                    align = NewAlign.Center;
                }
            }
            else
            {
                if (align == NewAlign.BottomLeft || align == NewAlign.TopLeft)
                {
                    align = NewAlign.Left;
                }
                else if (align == NewAlign.TopRight || align == NewAlign.BottomRight)
                {
                    align = NewAlign.Right;
                }
                else if (align == NewAlign.Top || align == NewAlign.Bottom)
                {
                    align = NewAlign.Center;
                }
            }
        }

        if (_ScrollRect != null)
        {
            if (IsVertical)
            {
                if (align == NewAlign.BottomLeft || align == NewAlign.Left || align == NewAlign.TopLeft)
                {
                    align = _IsInverseDirection ? NewAlign.TopLeft : NewAlign.BottomLeft;
                }
                else if (align == NewAlign.BottomRight || align == NewAlign.Right || align == NewAlign.TopRight)
                {
                    align = _IsInverseDirection ? NewAlign.TopRight : NewAlign.BottomRight;
                }
                else
                {
                    align = _IsInverseDirection ? NewAlign.Top : NewAlign.Bottom;
                }
            }
            else
            {
                if (align == NewAlign.BottomLeft || align == NewAlign.Bottom || align == NewAlign.BottomRight)
                {
                    align = _IsInverseDirection ? NewAlign.BottomRight : NewAlign.BottomLeft;
                }
                else if (align == NewAlign.TopLeft || align == NewAlign.Top || align == NewAlign.TopRight)
                {
                    align = _IsInverseDirection ? NewAlign.TopRight : NewAlign.TopLeft;
                }
                else
                {
                    align = _IsInverseDirection ? NewAlign.Right : NewAlign.Left;
                }
            }
        }

        Vector2 new_pos = GNewUITools.GetAlignedPivot(align);

        //Vector2 new_pos_cell = CellRect.anchorMin;

        //if (_ScrollRect != null)
        //{
        //    if (IsVertical)
        //    {
        //        new_pos.y = _IsInverseDirection ? 1 : 0;
        //    }
        //    else
        //    {
        //        new_pos.x = _IsInverseDirection ? 1 : 0;
        //    }
        //}

        CellRect.pivot = new_pos;
        Vector2 size = CellSize;

        //CellRect.anchorMax = new_pos_cell;
        //CellRect.anchorMin = new_pos_cell;
        //AdjustAnchor(CellRect, align);
        CellRect.anchorMax = new_pos;
        CellRect.anchorMin = new_pos;

        if (size.x > 0 && size.y > 0)
        {
            CellRect.sizeDelta = size;
        }

        rect.pivot = new_pos;
        //rect.anchorMax = new_pos;
        //rect.anchorMin = new_pos;
        //AdjustContentAnchor(rect, align);
        AdjustItemAnchor(rect);
    }