Beispiel #1
0
    protected virtual GListItem TryCreateItem()
    {
        if (CellTemplate == null)
        {
            return(null);
        }

        GListItem rv = null;

        rv = _CellPool.TakeOut();

        if (rv == null)
        {
            GameObject item    = CUnityUtil.Instantiate(CellTemplate.gameObject) as GameObject;
            GListItem  itemCon = GListItem.Get(item);
            itemCon.RectTrans.SetParent(_Content, false);

            rv = itemCon;

            if (HasChildButton && this.ClickItemButtonCallBack != null)
            {
                itemCon.OnItemClickButton = this.OnClickItemButton;
            }
        }

        GNewUITools.SetVisible(rv.RectTrans, true);

        return(rv);
    }
Beispiel #2
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);
    }
Beispiel #3
0
        protected LayoutItem TryCreateItem()
        {
            LayoutItem rv = null;

            rv = _Pool.TakeOut();
            if (rv == null)
            {
                RectTransform item = UGUITools.Instantiate(TemplateRect) as RectTransform;
                if (item != null)
                {
                    item.SetParent(CacheTransform, false);

                    LayoutItem item_com = item.GetComponent <LayoutItem>() ?? item.gameObject.AddComponent <LayoutItem>();

                    if (this.InitItemCallBack != null)
                    {
                        item_com.OnItemInit = this.OnShowItem;
                    }

                    if (this.ClickItemCallBack != null)
                    {
                        item_com.OnItemClick = this.OnClickItem;
                    }

                    if (this.LongPressCallBack != null)
                    {
                        item_com.OnItemLongPress = this.OnLongPressItem;
                    }

                    if (HasChildButton && this.ClickItemButtonCallBack != null)
                    {
                        item_com.OnItemClickButton = this.OnClickItemButton;
                    }

                    rv = item_com;
                }
            }

            if (rv != null)
            {
                UGUITools.SetVisible(rv.CacheRectTransform, true);
            }
            return(rv);
        }