private IEnumerator ShowItems() { while (Client.Instance.market == null) { yield return(new WaitForSecondsRealtime(0.1f)); } foreach (var item in Client.Instance.market) { string key = item.name; GameObject cloned = GameObject.Instantiate(ShelfItem); if (cloned == null) { continue; } cloned.SetActive(true); cloned.transform.SetParent(this.transform, false); ShelfItemUI handler = cloned.GetComponent <ShelfItemUI>(); if (handler == null) { continue; } handler.Init(item); market.Add(item.id, cloned); } }
private void OnEnable() { foreach (KeyValuePair <string, TreasureMall> goods in TreasureInfo.treasureMall) { string key = goods.Key; GameObject cloned = GameObject.Instantiate(ShelfItem); if (cloned == null) { continue; } cloned.SetActive(true); cloned.transform.SetParent(this.transform, false); ShelfItemUI handler = cloned.GetComponent <ShelfItemUI>(); if (handler == null) { continue; } handler.Init(key, goods.Value.price, goods.Value.isGold); //MessageBox.Show("mall: " + key); } }
// Use this for initialization void Start() { foreach (KeyValuePair <string, Sprite> kv in GetAllIcons.icons) { string key = kv.Key; GameObject cloned = GameObject.Instantiate(ShelfItem); if (cloned == null) { continue; } cloned.SetActive(true); cloned.transform.SetParent(this.transform, false); ShelfItemUI handler = cloned.GetComponent <ShelfItemUI>(); if (handler == null) { continue; } handler.Init(key); } ShelfItem.SetActive(false); }