void OnDeleteItem(GameObject item) { AudioController.Instance.SoundPlay("active_item"); GameObject parentGo = item.transform.parent.gameObject; ConfirmListItem temp = parentGo.GetComponent <ConfirmListItem>(); deleteSignal.Dispatch(temp.obj); itemList.Remove(parentGo); Destroy(parentGo); Grid.repositionNow = true; StartCoroutine(process()); }
public void CreateItems(List <ConfirmPanelObj> itemobjs) { Clear(); if (itemobjs.Count == 0) { return; } GameObject asset = (GameObject)AssetManager.Instance.LoadPrefab("ConfirmItem"); GameObject ItemObj = Instantiate(asset) as GameObject; ItemObj.transform.parent = Grid.transform; ItemObj.transform.localScale = Vector3.one; ItemObj.name = "0"; itemList.Add(ItemObj); for (int i = 1; i < itemobjs.Count; ++i) { GameObject go = Instantiate(ItemObj); go.transform.parent = ItemObj.transform.parent; go.transform.localScale = Vector3.one; go.name = i.ToString(); itemList.Add(go); } for (int i = 0; i < itemList.Count; ++i) { ConfirmListItem clItem = itemList[i].GetComponent <ConfirmListItem>(); clItem.FillContent(itemobjs[i]); UIEventListener.Get(clItem.DeleteBtn).onClick = OnDeleteItem; } Grid.repositionNow = true; StartCoroutine(process()); }