コード例 #1
0
 void InitItemPool()
 {
     foreach (StaggeredGridItemPrefabConfData data in mItemPrefabDataList)
     {
         if (data.mItemPrefab == null)
         {
             Debug.LogError("A item prefab is null ");
             continue;
         }
         string prefabName = data.mItemPrefab.name;
         if (mItemPoolDict.ContainsKey(prefabName))
         {
             Debug.LogError("A item prefab with name " + prefabName + " has existed!");
             continue;
         }
         RectTransform rtf = data.mItemPrefab.GetComponent <RectTransform>();
         if (rtf == null)
         {
             Debug.LogError("RectTransform component is not found in the prefab " + prefabName);
             continue;
         }
         AdjustAnchor(rtf);
         AdjustPivot(rtf);
         LoopStaggeredGridViewItem tItem = data.mItemPrefab.GetComponent <LoopStaggeredGridViewItem>();
         if (tItem == null)
         {
             data.mItemPrefab.AddComponent <LoopStaggeredGridViewItem>();
         }
         StaggeredGridItemPool pool = new StaggeredGridItemPool();
         pool.Init(data.mItemPrefab, data.mPadding, data.mInitCreateCount, mContainerTrans);
         mItemPoolDict.Add(prefabName, pool);
         mItemPoolList.Add(pool);
     }
 }
コード例 #2
0
        public void RecycleItemTmp(LoopStaggeredGridViewItem item)
        {
            if (Object.op_Equality((Object)item, (Object)null) || string.IsNullOrEmpty(item.ItemPrefabName))
            {
                return;
            }
            StaggeredGridItemPool staggeredGridItemPool = (StaggeredGridItemPool)null;

            if (!this.mItemPoolDict.TryGetValue(item.ItemPrefabName, out staggeredGridItemPool))
            {
                return;
            }
            staggeredGridItemPool.RecycleItem(item);
        }
コード例 #3
0
        public void RecycleItemTmp(LoopStaggeredGridViewItem item)
        {
            if (item == null)
            {
                return;
            }
            if (string.IsNullOrEmpty(item.ItemPrefabName))
            {
                return;
            }
            StaggeredGridItemPool pool = null;

            if (mItemPoolDict.TryGetValue(item.ItemPrefabName, out pool) == false)
            {
                return;
            }
            pool.RecycleItem(item);
        }
コード例 #4
0
        //This method is used to get a new item, and the new item is a clone from the prefab named itemPrefabName.
        //This method is usually used in onGetItemByItemIndex.
        public LoopStaggeredGridViewItem NewListViewItem(string itemPrefabName)
        {
            StaggeredGridItemPool pool = null;

            if (mItemPoolDict.TryGetValue(itemPrefabName, out pool) == false)
            {
                return(null);
            }
            LoopStaggeredGridViewItem item = pool.GetItem();
            RectTransform             rf   = item.GetComponent <RectTransform>();

            rf.SetParent(mContainerTrans);
            rf.localScale         = Vector3.one;
            rf.anchoredPosition3D = Vector3.zero;
            rf.localEulerAngles   = Vector3.zero;
            item.ParentListView   = this;
            return(item);
        }
コード例 #5
0
        public LoopStaggeredGridViewItem NewListViewItem(string itemPrefabName)
        {
            StaggeredGridItemPool staggeredGridItemPool = (StaggeredGridItemPool)null;

            if (!this.mItemPoolDict.TryGetValue(itemPrefabName, out staggeredGridItemPool))
            {
                return((LoopStaggeredGridViewItem)null);
            }
            LoopStaggeredGridViewItem staggeredGridViewItem = staggeredGridItemPool.GetItem();
            RectTransform             component             = (RectTransform)((Component)staggeredGridViewItem).GetComponent <RectTransform>();

            ((Transform)component).SetParent((Transform)this.mContainerTrans);
            ((Transform)component).set_localScale(Vector3.get_one());
            component.set_anchoredPosition3D(Vector3.get_zero());
            ((Transform)component).set_localEulerAngles(Vector3.get_zero());
            staggeredGridViewItem.ParentListView = this;
            return(staggeredGridViewItem);
        }
コード例 #6
0
 private void InitItemPool()
 {
     foreach (StaggeredGridItemPrefabConfData mItemPrefabData in this.mItemPrefabDataList)
     {
         if (Object.op_Equality((Object)mItemPrefabData.mItemPrefab, (Object)null))
         {
             Debug.LogError((object)"A item prefab is null ");
         }
         else
         {
             string name = ((Object)mItemPrefabData.mItemPrefab).get_name();
             if (this.mItemPoolDict.ContainsKey(name))
             {
                 Debug.LogError((object)("A item prefab with name " + name + " has existed!"));
             }
             else
             {
                 RectTransform component = (RectTransform)mItemPrefabData.mItemPrefab.GetComponent <RectTransform>();
                 if (Object.op_Equality((Object)component, (Object)null))
                 {
                     Debug.LogError((object)("RectTransform component is not found in the prefab " + name));
                 }
                 else
                 {
                     this.AdjustAnchor(component);
                     this.AdjustPivot(component);
                     if (Object.op_Equality((Object)mItemPrefabData.mItemPrefab.GetComponent <LoopStaggeredGridViewItem>(), (Object)null))
                     {
                         mItemPrefabData.mItemPrefab.AddComponent <LoopStaggeredGridViewItem>();
                     }
                     StaggeredGridItemPool staggeredGridItemPool = new StaggeredGridItemPool();
                     staggeredGridItemPool.Init(mItemPrefabData.mItemPrefab, mItemPrefabData.mPadding, mItemPrefabData.mInitCreateCount, this.mContainerTrans);
                     this.mItemPoolDict.Add(name, staggeredGridItemPool);
                     this.mItemPoolList.Add(staggeredGridItemPool);
                 }
             }
         }
     }
 }