/// <summary> /// 获取要解压的文件 /// </summary> /// <param name="verTextName"></param> /// <param name="callBack"></param> public void GetDecompressionTaskList(VerInfo localVer, Action <DecompressionOrDownInfo> callBack) { string sourceUrl = AppConst.SourceResPathUrl + "/" + localVer.verName + ".txt"; VerInfo remoteVer = null; Action <WWW> loadlocaled = www => { if (www != null && string.IsNullOrEmpty(www.error)) { try { remoteVer = JsonUtility.FromJson <VerInfo>(www.text); } catch (Exception) { Debug.LogError("本地没有这个文件:" + sourceUrl); } } else { Debug.LogError("本地没有这个文件:" + sourceUrl); } ComparisonInfo info = VerInfo.ComparisonVer(localVer, remoteVer); DecompressionOrDownInfo dord = new DecompressionOrDownInfo(); dord.remoteVer = remoteVer; dord.localVer = localVer; dord.comparisonInfo = info; if (callBack != null) { callBack(dord); } }; ComUtil.WWWLoad(sourceUrl, loadlocaled); }
public void GetDownList(VerInfo localVer, Action <DecompressionOrDownInfo> callBack) { if (downLoadInfo == null) { DecompressionOrDownInfo downInfo = new DecompressionOrDownInfo(); downInfo.localVer = localVer; downInfo.remoteVer = null; downInfo.comparisonInfo = VerInfo.ComparisonVer(localVer, downInfo.remoteVer); if (callBack != null) { callBack(downInfo); } return; } string remoturl = downLoadInfo.ResUrl + "/" + localVer.verName + ".txt"; VerInfo remoteVer = null; Debug.LogWarning("准备校验远程文件:" + remoturl); Action <WWW> wwwed = www => { if (www != null && string.IsNullOrEmpty(www.error)) { try { remoteVer = JsonUtility.FromJson <VerInfo>(www.text); } catch (System.Exception ex) { Debug.LogError("远程文件解析失败:text=" + www.text); } } else { Debug.LogError("从远程下载文件失败:url=" + remoturl); } ComparisonInfo info = VerInfo.ComparisonVer(localVer, remoteVer); if (localVer != null) { Debug.LogWarning("检查完成 本地版本:" + localVer.ver); } if (remoteVer != null) { Debug.LogWarning("检查完成 远程版本:" + remoteVer.ver); } DecompressionOrDownInfo dord = new DecompressionOrDownInfo(); dord.remoteVer = remoteVer; dord.localVer = localVer; dord.comparisonInfo = info; if (callBack != null) { callBack(dord); } www.Dispose(); }; Debug.LogWarning("从远程下载文件" + remoturl); ComUtil.WWWLoad(remoturl, wwwed); }