/// <summary> /// res config配置文件 和 资源文件 位于 同一目录下时使用该方法 /// </summary> /// <param name="remoteConfigFilePath">远程配置文件路径</param> /// <param name="localConfigFilePath">本地配置文件路径</param> /// <param name="callback"></param> /// <param name="checkVersion">是否判断res config的版本号,false:忽略版本号检测</param> /// <param name="checkItemExist">文件如果存在就不下载,不存在的时候再下载</param> public void StartResUpdate(string remoteConfigFilePath, string localConfigFilePath, Action <ResUpdateData> callback, bool checkVersion = true, bool checkItemExist = false) { mCheckVersion = checkVersion; mCheckItemExist = checkItemExist; onUpdateResCallback = callback; mRemoteResPath = remoteConfigFilePath.Substring(0, remoteConfigFilePath.LastIndexOf("/")); mLocalConfigFilePath = localConfigFilePath; mLocalResPath = Path.GetDirectoryName(localConfigFilePath); mResUpdateData = new ResUpdateData(); mUpdateItems = new Queue <ResItem>(); mLocalTempDir = Application.persistentDataPath + "/" + TempModuleResDir; ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true; StartCoroutine(PTModuleUpdateUtil.GetTextFromServer(remoteConfigFilePath, 3, OnGetServerConfigCallback)); }
private void OnResUpdateCallback(ResUpdateData resUpdateData) { switch (resUpdateData.status) { case UpdateStatus.FinishOneItem: mOnFinishedOneItem.InvokeGracefully(resUpdateData.finishedCount, resUpdateData.totalCount); break; case UpdateStatus.ReadyToDown: mOnReadyToDownload.InvokeGracefully(resUpdateData.totalCount, resUpdateData.totalSize); if (mOnReadyToDownload == null) { mResDown.StartDownLoadRes(); } break; case UpdateStatus.DownloadProgress: mOnDownloadProgress.InvokeGracefully(resUpdateData.finishedSize, resUpdateData.totalSize); break; default: mOnUpdateFinish.InvokeGracefully(resUpdateData.status, resUpdateData.msg, resUpdateData); break; } }