private IEnumerator DownLoad(string url, HandleFinishDownload finishFun) { WWW www = new WWW(url); while (!www.isDone) { if (DicMD5.Count > 0) { currentNum = (www.progress * int.Parse(DicMD5[DicMD5UpdateName[updateCount]][1])); } else { currentNum = www.progress; } // LoadPro = (((int)(www.progress * 100)) % 100) + "%"; //Debug.Log("进度:" + www.progress); //Debug.Log("进度:" + currentNum); //Debug.Log("进度:" + DicMD5[DicMD5UpdateName[updateCount]][1]); yield return(1); } yield return(www); if (finishFun != null) { finishFun(www); } www.Dispose(); }
//下载版本检测信息 private IEnumerator downLoadCheckVersion(string url, HandleFinishDownload finishFun) { WWW www = new WWW(url); yield return(www); Debug.Log("1111..."); //网络出错 if (!string.IsNullOrEmpty(www.error)) { DebugEx.Log(www.error, ResourceCommon.DEBUGTYPENAME); www.Dispose(); //检测网络连接 //yield return StartCoroutine(checkNetworkConnections()); //StartCoroutine(downLoad(url, finishFun)); } //成功 else { if (finishFun != null) { finishFun(www); } www.Dispose(); } }
private IEnumerator DownLoad(string url, bool isRes, HandleFinishDownload finishFun) { WWW www = new WWW(url); if (isRes) { loadResIdx++; } while (isRes && !www.isDone) { if (www.progress > 0.01f) { SendDownLoadProgressArgs(loadResIdx, url, www.progress); yield return(null); downLoadTime += Time.deltaTime; } } yield return(www); if (finishFun != null) { finishFun(www); } www.Dispose(); }
private IEnumerator DownLoad(string url, HandleFinishDownload finishFun) { WWW www = new WWW(url); yield return(www); if (finishFun != null) { finishFun(www); } www.Dispose(); }
/// <summary> /// 下载资源 /// </summary> /// <param name="url">url</param> /// <param name="handle">下载完成回调</param> /// <param name="timeout">超时时间</param> /// <param name="errorCall">超时或错误回调</param> /// <returns></returns> private IEnumerator Download(string url, long length, HandleFinishDownload handle, int timeout = 10000, HandleDownloadError errorCall = null) { DebugConsole.Log("==>Download url = " + url); //创建download info curDownload.url = url; curDownload.length = length; curDownload.timeout = timeout; curDownload.errorCallback = errorCall; curDownload.flag = true; curDownload.www = new WWW(url); //打开下载路径 //DebugConsole.Log("new www"); yield return(curDownload.www); //等待下载完成 //下载完成后 DebugConsole.Log("<==www return url = " + url); WWW doneWWW = curDownload.www; //保存下载好的info curDownloadLength += curDownload.length; //重置curDownload参数 curDownload.Reset(); if (string.IsNullOrEmpty(doneWWW.error)) { if (handle != null) //回调不为空 { handle(doneWWW); //传递下载信息 } doneWWW.Dispose(); //释放资源 //doneInfo.Reset(); doneWWW = null; } else { DebugConsole.LogError("WWW Error = " + doneWWW.error); try { if (errorCall != null) { errorCall.Invoke(); } } catch (System.Exception ex) { DebugConsole.LogError("Error Handle Callback Exception!"); DebugConsole.LogError(ex.Message); DebugConsole.LogError(ex.StackTrace); } } }
///// <summary> ///// 复制文件到外部存储 ///// </summary> //private void loadLocalData() //{ // StartCoroutine(DownLoad(@"file:///" + Application.dataPath + "/StreamingAssets/" + VERSION_FILE, delegate(WWW localVersion) // { // ReplaceLocalRes(VERSION_FILE, localVersion.bytes); // })); //} private IEnumerator DownLoad(string url, HandleFinishDownload finishFun) { WWW www = new WWW(url); yield return(www); //if (www.error != null) // Debug.LogError("url = " + url + ". error = " + www.error); if (finishFun != null) { finishFun(www); } www.Dispose(); }
private IEnumerator DownLoad(string url, HandleFinishDownload finishFun) { // Debug.Log("Begin Downlaod"); WWW www = new WWW(url); Debug.Log("------------------------" + www.progress); yield return(www); Debug.Log("------------------------" + www.progress); if (finishFun != null) { finishFun(www); } www.Dispose(); // Debug.Log("End Download"); }
public IEnumerator LoadEachTexture(string url, HandleFinishDownload finishFunc) { WWW www = new WWW(url); yield return(www); if (www.error == null || www.error == "") { finishFunc(www); } else { LoadEachTexture(url, finishFunc); } { // Debug.LogError("url"+url+"error:" + www.error); } www.Dispose(); }
///---------------------------------------------------------------------------------------------- /// <summary> /// 下载 Asset 自愿 /// </summary> ///---------------------------------------------------------------------------------------------- private IEnumerator DownLoadAsset(string url, HandleFinishDownload finishFun) { if (mCurDownLoadAsset == url) { ++mCurDownLoadAssetFailedTimes; } else { mCurDownLoadAssetFailedTimes = 0; mCurDownLoadAsset = url; } if (mCurDownLoadAssetFailedTimes > mMaxRepeatDownLoadTimes) { mForceTermination = true; yield break; } WWW www = new WWW(url); yield return(www); if (!string.IsNullOrEmpty(www.error)) { Common.DEBUG_MSG(www.error); www.Dispose(); //检测网络连接 yield return(StartCoroutine(checkNetworkConnections())); StartCoroutine(DownLoadAsset(url, finishFun)); } else { if (finishFun != null) { finishFun(www); } www.Dispose(); } }
private IEnumerator DownLoadFile(string url, HandleFinishDownload onFinishedDownload) { DebugUtils.Log(DebugUtils.Type.DownloadResource, string.Format("Down load file url :{0}", url)); WWW www = new WWW(url); yield return(www); if (!www.isDone || !string.IsNullOrEmpty(www.error)) { DebugUtils.LogError(DebugUtils.Type.DownloadResource, string.Format("Down load file failed! error msg:{0} isDone:{1} url = {2}", www.error, www.isDone, url)); onFinishedDownload(null); } else { onFinishedDownload(www); } www.Dispose(); www = null; }
///---------------------------------------------------------------------------------------------- /// <summary> /// 从服务器上下载当前版本信息 /// </summary> ///---------------------------------------------------------------------------------------------- private IEnumerator downLoadCheckVersion(string url, HandleFinishDownload finishFun) { WWW www = new WWW(url); yield return(www); /// 网络出问题 if (!string.IsNullOrEmpty(www.error)) { Common.DEBUG_MSG(www.error); www.Dispose(); } else { /// 访问操作执行成功 if (finishFun != null) { finishFun(www); } www.Dispose(); } }
private IEnumerator DownLoad(string url, HandleFinishDownload finishFun) { WWW www = new WWW(url); yield return www; if (finishFun != null) { finishFun(www); } www.Dispose(); }
private IEnumerator DownLoad(string url, HandleFinishDownload finishFun) { WWW www = new WWW(url); while (!www.isDone) yield return null; //yield return www; if(www.error != null) { //文件不存在 Debug.Log(www.error); } else { if (finishFun != null) { finishFun(www); } //www.Dispose(); } }
public IEnumerator LoadBundle(string bundleName, HandleFinishDownload finishFun) { string patchUrl = ""; if (System.IO.File.Exists(LOCAL_CACHE + bundleName)) { //patch = LOCAL_CACHE; patchUrl = LOCAL_CACHE_URL; } else// if (System.IO.File.Exists(LOCAL_RES + bundleName))//streamingAssets 目录在安卓下是压缩包,不能用接口检测存不存在 { //patch = LOCAL_RES; patchUrl = LOCAL_RES_URL; } WWW www = new WWW(patchUrl + bundleName); while (!www.isDone) yield return null; //yield return www; if (www.error != null) { //文件不存在 Debug.LogError(patchUrl + bundleName + "is not exit!"); } else { if (finishFun != null) { finishFun(www); } //www.Dispose(); } }