// void OnUpateItem(GameObject go, int index, int realIndex, List <Model_Unit> dataList, Dictionary <int, TankRepairItem> dataDic) { int index_ = 0; int indexList = Mathf.Abs(realIndex); int tankCount = dataList.Count; TankRepairItem Item1 = go.transform.Find("TankRepairItem1").GetComponent <TankRepairItem>(); TankRepairItem tankItem2 = go.transform.Find("TankRepairItem2").GetComponent <TankRepairItem>(); index_ = indexList * 2; if (index_ > (tankCount - 1)) { Item1.gameObject.SetActive(false); tankItem2.gameObject.SetActive(false); return; } else { Item1.gameObject.SetActive(true); Item1.Init(dataList[index_]); if (!dataDic.ContainsKey(dataList[index_].unitId)) { dataDic.Add(dataList[index_].unitId, Item1); } else { dataDic.Remove(dataList[index_].unitId); dataDic.Add(dataList[index_].unitId, Item1); } } index_ = indexList * 2 + 1; if (index_ > (tankCount - 1)) { tankItem2.gameObject.SetActive(false); return; } else { tankItem2.gameObject.SetActive(true); tankItem2.Init(dataList[index_]); if (!dataDic.ContainsKey(dataList[index_].unitId)) { dataDic.Add(dataList[index_].unitId, tankItem2); } else { dataDic.Remove(dataList[index_].unitId); dataDic.Add(dataList[index_].unitId, tankItem2); } } }
void CreateWrapTankItem(List <Model_Unit> dataList) { int count = dataList.Count; if (_repairGrid != null) { _repairGrid.DestoryAllChildren(); } _tankRepairItemDic.Clear(); for (int i = 0; i < count; i++) { if (_repairGrid.gameObject != null) { GameObject tankItem = (GameObject)Resources.Load(AppConfig.FOLDER_PROFAB_UI + "RepairFactory/TankRepairItem"); GameObject item = NGUITools.AddChild(_repairGrid.gameObject, tankItem); TankRepairItem repairItem = item.GetComponent <TankRepairItem>(); repairItem.Init(dataList[i]); _tankRepairItemDic.Add(dataList[i].unitId, repairItem); } } _repairGrid.Reposition(); }