/// <summary> /// 获取子包 /// </summary> private void OnClick_GetSubPackage() { var url = "http://" + inputField.text; BResources.GetServerSubPacks(url, (map) => { //获取到子包 Debug.Log("获取到子包信息:\n" + JsonMapper.ToJson(map, true)); //全隐藏 var grid = this.transform.Find("grid_SubPack"); foreach (Transform child in grid) { child.gameObject.SetActive(false); } //显示 var idx = 0; foreach (var kv in map) { var btn = grid.GetChild(idx)?.GetComponent <Button>(); btn.gameObject.SetActive(true); btn.onClick.RemoveAllListeners(); btn.transform.GetChild(0).GetComponent <Text>().text = "下载子包:" + kv.Key; //添加监听 btn.onClick.AddListener(() => { //下载 this.Onclick_DownloadSubPackageLoadAndLaunch((kv.Key)); }); idx++; } }); }