Ejemplo n.º 1
0
        public LoopListViewItem2 GetItem()
        {
            mCurItemIdCount++;
            LoopListViewItem2 tItem = null;

            if (mTmpPooledItemList.Count > 0)
            {
                int count = mTmpPooledItemList.Count;
                tItem = mTmpPooledItemList[count - 1];
                mTmpPooledItemList.RemoveAt(count - 1);
                tItem.gameObject.SetActive(true);
            }
            else
            {
                int count = mPooledItemList.Count;
                if (count == 0)
                {
                    tItem = CreateItem();
                }
                else
                {
                    tItem = mPooledItemList[count - 1];
                    mPooledItemList.RemoveAt(count - 1);
                    tItem.gameObject.SetActive(true);
                }
            }
            tItem.Padding = mPadding;
            tItem.ItemId  = mCurItemIdCount;
            return(tItem);
        }
Ejemplo n.º 2
0
 public void Init(GameObject prefabObj, float padding, float startPosOffset, int createCount, RectTransform parent)
 {
     mPrefabObj       = prefabObj;
     mPrefabName      = mPrefabObj.name;
     mInitCreateCount = createCount;
     mPadding         = padding;
     mStartPosOffset  = startPosOffset;
     mItemParent      = parent;
     mPrefabObj.SetActive(false);
     for (int i = 0; i < mInitCreateCount; ++i)
     {
         LoopListViewItem2 tViewItem = CreateItem();
         RecycleItemReal(tViewItem);
     }
 }
Ejemplo n.º 3
0
        public LoopListViewItem2 CreateItem()
        {
            GameObject go = GameObject.Instantiate <GameObject>(mPrefabObj, Vector3.zero, Quaternion.identity, mItemParent);

            go.SetActive(true);
            RectTransform rf = go.GetComponent <RectTransform>();

            rf.localScale         = Vector3.one;
            rf.anchoredPosition3D = Vector3.zero;
            rf.localEulerAngles   = Vector3.zero;
            LoopListViewItem2 tViewItem = go.GetComponent <LoopListViewItem2>();

            tViewItem.ItemPrefabName = mPrefabName;
            tViewItem.StartPosOffset = mStartPosOffset;
            return(tViewItem);
        }
Ejemplo n.º 4
0
 void RecycleItemReal(LoopListViewItem2 item)
 {
     item.gameObject.SetActive(false);
     mPooledItemList.Add(item);
 }
Ejemplo n.º 5
0
 public void RecycleItem(LoopListViewItem2 item)
 {
     // 避免刷新时视图跳动
     //mTmpPooledItemList.Add(item);
     mTmpPooledItemList.Insert(0, item);
 }