这个脚本是用来下载assetbuild的 unity2017.3的UnityWebRequest新增了DownloadHandlerFile的支持函数,可以直接将文件下载到外存(可以少写很多代码),也用来把StreamingAssets里的文件复制到persistentDataPath(在移动端C#的IO库好像读不了StreamingAssets里的文件)
*unity2017.2的UnityWebRequest新增timeout属性,用来设置超时时间(又可以少写很多代码)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
using System;
using System.IO;
public class ABDownLoad : MonoBehaviour
{
float m_downCount=0;
public void Download(string _newFileIP, string _newFilesPath,string _oldFilesPath,Action<float> _peogress)
{
StartCoroutine (download(_newFileIP,_newFilesPath,_oldFilesPath,_peogress));
}
IEnumerator download(string _newFileIP, string _newFilesPath,string _oldFilesPath,Action<float> _peogress)
{
string newFilesJson;
string loadNewFileUrl = _newFileIP + "/" + _newFilesPath;
if(loadNewFileUrl.IndexOf("file:///")==-1 && loadNewFileUrl.IndexOf("http")!=0)
{
loadNewF