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); } }
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); } } } } }