using CG.UTility; using System.Collections; using System.Collections.Generic; using System.IO; using UnityEngine; using UnityEngine.Networking; using UnityEngine.Playables; /******************************************************************************* *Create By CG *Function *******************************************************************************/ namespace Test { public class CreateGeo : MonoBehaviour { private string a = "注射器|孕酮阴道栓(CIDR)|长柄钳|氯前列烯醇|前列腺素(PG)|消毒纸巾|促卵泡生成素(FSH)|孕马血清促性腺激素(PMSG)|聚乙烯哔咯烷酮(PVP)|卡波前列腺素(甲基-PGF2α)显微镜|载玻片|盖玻片|玻璃棒|恒温载物台|输精器|外套管|保定架|一次性长臂塑料手套|恒温水浴锅|镊子|细管剪|0.3%高锰酸钾|扩张棒|冲卵管|注射器|容器|冲卵液|青霉素|链霉素"; //public GameObject prefab; //public Transform parnet; //[ContextMenu("CreateGeo")] //void CreateGeoM() //{ // string[] aArray = a.Split("|"); // for (int i = 0; i < aArray.Length; i++) // { // GameObject b = Instantiate(prefab, parnet); // b.name = aArray[i]; // b.transform.localPosition = new Vector3(i, 0, 0); // } //} private string[] imgcontains = new[] { "zhixiankuang.png","zhejiaokuang.png", "lock.png", "UI/voice.png", "UI/score.png", "UI/Pause.png", "UI/home.png", "UI/goldcoin.png", "UI/continue.png", "zhixian.png", "zhejiao.png", "select.png", "border.png" }; private string[] audcontains = new[] { "audio/chupai.mp3","audio/lianshang.mp3", "audio/kaishi.mp3", "audio/shu.mp3", "audio/beijing.mp3" }; private void Update() { if (Input.GetKeyDown(KeyCode.A)) { // transform.GetComponent().PlayForward(); for (int i = 0; i < audcontains.Length; i++) { StartCoroutine(DownloadFile( "https://a.unity.cn/client_api/v1/buckets/fe3af405-0d0f-4138-8562-1f8f55fc58eb/content/"+audcontains[i], "C:/Users/Admin/Desktop/image/"+audcontains[i])); } } } /// /// 网络下载文件 /// /// 下载地址 /// 地址样例 "http://**********" /// 保存路径 需带后缀名字 /// IEnumerator DownloadFile(string url,string savePath) { Debug.Log("开始下载"); UnityWebRequest www = UnityWebRequest.Get(url); yield return www.SendWebRequest(); if (www.result == UnityWebRequest.Result.Success) { File.WriteAllBytes(savePath, www.downloadHandler.data); Debug.Log("下载成功"); } else { Debug.LogError("下载失败: " + www.error); } } } }