public IEnumerator Open() { gameObject.SetActive(true); complete = false; if (null != products) { foreach (Product product in products) { product.transform.SetParent(null); Object.Destroy(product.transform.gameObject); } } products = new List <Product>(); Transform slots = UIUtil.FindChild <Transform>(transform, "ItemSlots"); Transform productPrefab = UIUtil.FindChild <Transform>(slots, "ItemSlot"); productPrefab.gameObject.SetActive(false); for (int i = 0; i < PRODUCT_COUNT; i++) { int index = i; Product product = new Product(); product.index = i; product.transform = GameObject.Instantiate <Transform>(productPrefab); product.transform.SetParent(slots, false); product.transform.gameObject.SetActive(true); UIUtil.AddPointerUpListener(product.transform.gameObject, () => { SelectProduct(index); }); product.outline = product.transform.GetComponent <ImageOutline>(); product.item_image = UIUtil.FindChild <Image>(product.transform, "Item"); product.soldout_image = UIUtil.FindChild <Image>(product.transform, "Soldout"); product.soldout_image.gameObject.SetActive(false); product.soldout = false; InitProduct(product, ItemManager.Instance.GetRandomExpendableItemMeta()); products.Add(product); } InitProduct(products[Random.Range(0, products.Count)], ItemManager.Instance.FindMeta <HealPotionItem.Meta>("ITEM_POTION_HEALING")); SelectProduct(0); Util.EventSystem.Publish(EventID.CoinAmountChanged); while (false == complete) { yield return(null); } gameObject.SetActive(false); }