internal void Getcategory(string _json) { Categroylist tmp = Browser.Getinstance().Getdatafromjson <Categroylist>(_json); if (categroy.result == null) { return; } //计算服务器返回数据的长度 int count = tmp.result.Count - categroy.result.Count; if (count > 0) { Showcaseview showcase = Getviewfromviewid(typeof(Showcaseview).Name) as Showcaseview; for (int i = 0; i < count; i++) { categroy.result.Add(new Categroy()); } for (int i = 0; i < categroy.result.Count; i++) { categroy.result[i] = tmp.result[i]; Categorysetup cs = Uiprefabcreator.Uicreator(showcase.verticalroot, showcase.verticalprefab) .GetComponent <Categorysetup>(); cs.title.text = categroy.result[i].alias; categroygos.Add(categroy.result[i].category, cs.gameObject); } } StartCoroutine(Waittoload()); }
/// <summary> /// 创建资源item /// </summary> /// <param name="_json"></param> internal void Getitems(string _json) { Itemlist tmp = Browser.Getinstance().Getdatafromjson <Itemlist>(_json); if (itemlist.result == null) { return; } int count = tmp.result.Count - itemlist.result.Count; if (count > 0) { Showcaseview showcase = Getviewfromviewid(typeof(Showcaseview).Name) as Showcaseview; for (int i = 0; i < tmp.result.Count; i++) { itemlist.result.Add(tmp.result[i]); GameObject tmpgo = Uiprefabcreator.Uicreator(null, showcase.horizontalprefab); Itemsetup cs = tmpgo.GetComponent <Itemsetup>(); cs.unitid = tmp.result[i].trackerid; cs.item = itemlist.result[i]; items.Add(cs); } for (int i = 0; i < itemlist.result.Count; i++) { //set parent GameObject categroy_root = null; categroygos.TryGetValue(itemlist.result[i].category, out categroy_root); GameObject item = null; items[i].transform.SetParent(categroy_root.transform.GetComponent <Categorysetup>().itemroot); items[i].transform.localScale = Vector3.one; items[i].transform.localPosition = Vector3.zero; items[i].title.text = itemlist.result[i].itemname; items[i].unitid = itemlist.result[i].trackerid; Browser.Getinstance() .GetMarkless(itemlist.result[i].thumbnails, Setthumbnails, null, items[i].background); } } }