void CreateItem(List <SlgPB.PVPUser> _pvpUsers) { _playItemList.Clear(); _Grid.DestoryAllChildren(); int dataCount = _pvpUsers.Count; if (dataCount > 5) { _Grid.pivot = UIWidget.Pivot.Right; _scrollview.enabled = true; } else { _Grid.pivot = UIWidget.Pivot.Center; _scrollview.enabled = false; } for (int i = 0; i < dataCount; i++) { GameObject prefab = (GameObject)Resources.Load(AppConfig.FOLDER_PROFAB_UI + "pvp/playItem"); GameObject item = NGUITools.AddChild(_Grid.gameObject, prefab); PlayItem playitem = item.GetComponent <PlayItem>(); item.name = "0" + i; playitem.Init(_pvpUsers[i]); _playItemList.Add(playitem); } _Grid.Reposition(); }
void OnUpateItem(GameObject go, int index, int realIndex, List <SlgPB.PVPUser> dataList, Dictionary <int, PlayItem> dataDic) { int dataCount = dataList.Count; int indexList = Mathf.Abs(realIndex); PlayItem Item1 = go.GetComponent <PlayItem>(); int index_ = indexList; if (index_ > (dataCount - 1)) { Item1.gameObject.SetActive(false); return; } else { Item1.gameObject.SetActive(true); Item1.Init(dataList[index_]); if (!dataDic.ContainsKey(dataList[index_].userId)) { dataDic.Add(dataList[index_].userId, Item1); } } }