IEnumerator RefreshItemList(ETravelBackpackItemType TBIType) { List <ulong> IDLst = new List <ulong>(); for (int i = 0; i < CurTypeGrids.Count; i++) { for (int j = 0; j < CurTypeGrids[i].transform.childCount; j++) { Transform child = CurTypeGrids[i].transform.GetChild(j); if (child.name.Contains("GridInfo_")) { IDLst.Add(ulong.Parse(MyTools.GetLastString(child.name, '_'))); } } } MyTools.DestroyImmediateChildNodes(ItemGrid.transform); UIScrollView sv = ItemGrid.transform.parent.GetComponent <UIScrollView>(); if (GameApp.Instance.PlayerData != null) { PlayerBag pb = GameApp.Instance.PlayerData.m_player_bag; for (int i = 0, p = 0; i < pb.m_items.Count; i++) { ItemConfig ItemCfg = null; CsvConfigTables.Instance.ItemCsvDic.TryGetValue((int)pb.m_items[i].m_item_id, out ItemCfg); if (ItemCfg != null) { if (ItemCfg.Type == 10 + (int)TBIType) { GameObject newUnit = NGUITools.AddChild(ItemGrid.gameObject, ItemUnitPrefab); newUnit.SetActive(true); newUnit.name = "ItemUnit_" + p; newUnit.transform.localPosition = new Vector3(0, -150 * p / 3, 0); UI_Travel_Backpack_ItemUnit iu = newUnit.GetComponent <UI_Travel_Backpack_ItemUnit>(); iu.SetItemData(pb.m_items[i], ItemCfg, IDLst); ItemGrid.repositionNow = true; sv.ResetPosition(); yield return(new WaitForEndOfFrame()); p++; } } } } }
public void ShowItemLst(ETravelBackpackItemType TBIType, GameObject Obj) { CurWaitSetGridObj = Obj; TweenAlpha.Begin(ItemLstRoot, 0.1f, 1); if ((int)TBIType >= TypeTog.Length) { CurTypeGrids.Clear(); TypeTog[0].value = true; for (int i = 0; i < TypeTog.Length; i++) { TypeTog[i].gameObject.GetComponent <BoxCollider>().enabled = true; UISprite BackgroundSpr = TypeTog[i].transform.Find("Background").GetComponent <UISprite>(); BackgroundSpr.spriteName = "btn_anjian_1"; UISprite CheckmarkSpr = TypeTog[i].transform.Find("Checkmark").GetComponent <UISprite>(); CheckmarkSpr.spriteName = "btn_anjian_2"; CheckmarkSpr.width = 176; CheckmarkSpr.height = 67; } StartCoroutine("RefreshItemList", ETravelBackpackItemType.eFood); } else { TypeTog[(int)TBIType].value = true; for (int i = 0; i < TypeTog.Length; i++) { TypeTog[i].gameObject.GetComponent <BoxCollider>().enabled = false; UISprite BackgroundSpr = TypeTog[i].transform.Find("Background").GetComponent <UISprite>(); BackgroundSpr.spriteName = "btn_anjian_0"; UISprite CheckmarkSpr = TypeTog[i].transform.Find("Checkmark").GetComponent <UISprite>(); CheckmarkSpr.spriteName = "sdgsg"; CheckmarkSpr.width = 194; CheckmarkSpr.height = 74; } StartCoroutine("RefreshItemList", TBIType); } }