Exemplo n.º 1
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);
        }