最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Unity3D實(shí)現(xiàn)批量下載圖片功能

 更新時(shí)間:2018年07月20日 08:46:50   作者:AWNUXCVBN  
這篇文章主要為大家詳細(xì)介紹了Unity3D實(shí)現(xiàn)批量下載圖片功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了Unity3D實(shí)現(xiàn)批量下載圖片功能的具體代碼,供大家參考,具體內(nèi)容如下

下一篇文章試試用線程下載

代碼如下

using System.IO;
using UnityEngine;
using System.Net;
using System.Collections;
 
public class Test : MonoBehaviour {
 
  private string[] _urls=new string[10];
  private string [] _localPath = new string[10];
 
 // Use this for initialization
 void Start () 
  {
    for (int i = 0; i < _urls.Length; i++)
    {
      //所有圖片的下載地址
      _urls[i] = "http://192.168.1.41:8080/Test/picture/" + (i + 1).ToString() + ".jpg";
      //所有圖片的保存路徑
      _localPath[i] = Application.dataPath + "/Resources/" + (i + 1).ToString() + ".jpg";
      
    }
 }
 
  // Update is called once per frame
  void Update() 
  {
 
 }
 
  void OnGUI()
  {
    if (GUI.Button(new Rect(0, 0, 100, 30), "下載所有圖片"))
    {
      DownLoad();
    }
    //判斷文件是否已下載
    for (int i = 0; i < _urls.Length; i++)
    {
      if (File.Exists(_localPath[i]))
      {
        GUI.Button(new Rect(0, 30 * i+30, 50, 30), (i + 1).ToString());
      }
    }
 
    
  }
 
  //下載所有圖片
  private void DownLoad()
  {
    for (int i = 0; i < _urls.Length; i++)
    {
      DownLoadAllImages(_urls[i], _localPath[i]);
    }
  }
 
 
  void DownLoadAllImages(string url, string localPath)
  {
    WebClient web = new WebClient();
    web.DownloadFile(url, localPath);
    //以下代碼下載完成后執(zhí)行
  }
}

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

您可能感興趣的文章:

相關(guān)文章

最新評論

资源县| 固安县| 桂平市| 府谷县| 临沂市| 左贡县| 广南县| 芦山县| 沂水县| 临沂市| 视频| 昭苏县| 扎囊县| 赫章县| 德钦县| 仙桃市| 大姚县| 永川市| 西平县| 宁阳县| 南通市| 香港| 乌鲁木齐市| 新和县| 普安县| 桐乡市| 马公市| 石柱| 汶川县| 满城县| 亳州市| 衡东县| 长葛市| 墨江| 育儿| 昆山市| 盐城市| 岳西县| 绩溪县| 上虞市| 遂川县|