private IEnumerator RequestCopy() { var v1 = Versions.LoadVersion(_savePath + Versions.Filename); var basePath = GetBasePath(); var request = UnityWebRequest.Get(Path.Combine(basePath, Versions.Filename)); var path = _savePath + Versions.Filename + ".tmp"; request.downloadHandler = new DownloadHandlerFile(path); yield return(request.SendWebRequest()); var v2 = -1; var hasFile = string.IsNullOrEmpty(request.error); if (hasFile) { v2 = Versions.LoadVersion(path); } var steamFileThenSave = v2 > v1; if (steamFileThenSave) { Debug.LogWarning("本地流目录版本高于网络目录版本"); } _step = hasFile && steamFileThenSave ? Step.Coping : Step.Versions; request.Dispose(); }
private IEnumerator RequestCopy() { var v1 = Versions.LoadVersion(_savePath + Versions.Filename); var basePath = GetStreamingAssetsPath() + "/"; var request = UnityWebRequest.Get(basePath + Versions.Filename); var path = _savePath + Versions.Filename + ".tmp"; request.downloadHandler = new DownloadHandlerFile(path); yield return(request.SendWebRequest()); if (string.IsNullOrEmpty(request.error)) { var v2 = Versions.LoadVersion(path); if (v2 > v1) { var mb = MessageBox.Show("提示", "是否将资源解压到本地?", "解压", "跳过"); yield return(mb); if (mb.isOk) { var versions = Versions.LoadVersions(path); yield return(UpdateCopy(versions, basePath)); } } else { Versions.LoadVersions(path); } } request.Dispose(); }
private void OnComplete() { OnProgress(1); OnMessage("更新完成"); OnVersion(Versions.LoadVersion(_savePath + Versions.Filename).ToString()); StartCoroutine(LoadGameScene()); }
private IEnumerator RequestCopy() { var v1 = offline? -1 : Versions.LoadVersion(_savePath + Versions.Filename);//这个是服务器版本 var basePath = GetBasePath(); var request = UnityWebRequest.Get(Path.Combine(basePath, Versions.Filename)); var path = _savePath + Versions.Filename + ".tmp"; request.downloadHandler = new DownloadHandlerFile(path); yield return(request.SendWebRequest()); var v2 = -1;//这个是本地版本 var hasFile = string.IsNullOrEmpty(request.error); if (hasFile) { v2 = Versions.LoadVersion(path); } var steamFileThenSave = v2 >= v1; if (steamFileThenSave) { Debug.LogWarning(offline?"离线模式直接解压本地资源":"本地流目录版本高于或等于网络目录版本"); } _step = hasFile && steamFileThenSave ? Step.Coping : Step.Versions; if (!hasFile && offline) { var mb = MessageBox.Show("提示", "离线模式需要将资源拷贝到本地,目前检测不到,因此游戏无法正常运行"); yield return(mb); Quit(); } request.Dispose(); }
private void OnComplete() { if (this.EnableVFS) { var dataPath = _savePath + Versions.Dataname; var downloads = _downloader.downloads; if (downloads.Count > 0 && File.Exists(dataPath)) { OnMessage("更新本地版本信息"); var files = new List <VFile>(downloads.Count); foreach (var download in downloads) { files.Add(new VFile { name = download.name, hash = download.hash, len = download.len, }); } var file = files[0]; if (!file.name.Equals(Versions.Dataname)) { Versions.UpdateDisk(dataPath, files); } } Versions.LoadDisk(dataPath); } OnProgress(1); OnMessage($"更新完成,版本号:{Versions.LoadVersion(_savePath + Versions.Filename)}"); StartCoroutine(LoadGameScene()); }
private IEnumerator RequestCopy() { var v1 = Versions.LoadVersion(_savePath + Versions.Filename); var basePath = GetStreamingAssetsPath() + "/"; var request = UnityWebRequest.Get(basePath + Versions.Filename); var path = _savePath + Versions.Filename + ".tmp"; request.downloadHandler = new DownloadHandlerFile(path); yield return(request.SendWebRequest()); if (string.IsNullOrEmpty(request.error)) { var v2 = Versions.LoadVersion(path); if (v2 > v1) { Debug.Log("将资源解压到本地"); this.Step = Step.Coping; } else { Versions.LoadVersions(path); this.Step = Step.Versions; } } else { this.Step = Step.Versions; } request.Dispose(); }
private IEnumerator RequestCopy() { var v1 = Versions.LoadVersion(_savePath + Versions.Filename); var basePath = GetBasePath(); var request = UnityWebRequest.Get(basePath + Versions.Filename); var path = _savePath + Versions.Filename + ".tmp"; request.downloadHandler = new DownloadHandlerFile(path); yield return(request.SendWebRequest()); _step = string.IsNullOrEmpty(request.error) ? Step.Coping : Step.Versions; request.Dispose(); }
private void Start() { try { version.text = "资源版本号: v" + Versions.LoadVersion(Application.persistentDataPath + '/' + Versions.Filename); } catch (Exception e) { version.text = "初始版本"; } var updater = FindObjectOfType <Updater>(); updater.listener = this; }
private void OnComplete() { if (enableVFS) { var dataPath = _savePath + Versions.Dataname; var downloads = _downloader.downloads; if (downloads.Count > 0 && File.Exists(dataPath)) { OnMessage("更新本地版本信息"); var files = new List <VFile>(downloads.Count); foreach (var download in downloads) { files.Add(new VFile { name = Path.GetFileName(download.savePath), hash = download.hash, len = download.len, }); } var file = files[0]; if (!file.name.Equals(Versions.Dataname)) { Versions.UpdateDisk(dataPath, files); } } Versions.LoadDisk(dataPath); } OnProgress(1); OnMessage("更新完成"); var version = Versions.LoadVersion(_savePath + Versions.Filename); if (version > 0) { OnVersion(version.ToString()); } _step = STEP_COMPLETE; StartCoroutine(LoadGameScene()); }
private void OnComplete() { if (enableVFS) { var dataPath = _savePath + Versions.Dataname; var downloads = _downloader.downloads; if (downloads.Count > 0 && File.Exists(dataPath)) { OnMessage("更新本地版本信息"); var files = new List <VFile>(downloads.Count); foreach (var download in downloads) { files.Add(new VFile { name = download.name, hash = download.hash, len = download.len, }); } var file = files[0]; if (!file.name.Equals(Versions.Dataname)) { Versions.UpdateDisk(dataPath, files); } } Versions.LoadDisk(dataPath); } OnProgress(1); OnMessage("更新完成"); var version = Versions.LoadVersion(_savePath + Versions.Filename); if (version > 0) { OnVersion(version.ToString()); } //StartCoroutine(LoadGameScene()); FrameworkBoot.Event.Fire(StartBootResSystemEventArgs.EventId, StartBootResSystemEventArgs.Create(1)); }
private IEnumerator RequestVersions() { OnMessage("正在获取版本信息..."); if (Application.internetReachability == NetworkReachability.NotReachable) { var mb = MessageBox.Show("提示", "请检查网络连接状态", "重试", "退出"); yield return(mb); if (mb.isOk) { StartUpdate(); } else { Quit(); } yield break; } var request = UnityWebRequest.Get(GetDownloadURL(Versions.Filename)); request.downloadHandler = new DownloadHandlerFile(_savePath + Versions.Filename); yield return(request.SendWebRequest()); var error = request.error; request.Dispose(); if (!string.IsNullOrEmpty(error)) { var mb = MessageBox.Show("提示", string.Format("获取服务器版本失败:{0}", error), "重试", "退出"); yield return(mb); if (mb.isOk) { StartUpdate(); } else { Quit(); } yield break; } try { var v1 = Versions.LoadVersion(_savePath + Versions.Filename); //网络版本文件 var v2 = Versions.LoadVersion(_savePath + Versions.Filename + ".tmp"); //本地临时文件 if (v2 > v1) { //如果本地版本高于网络版本,就别更新了 OnComplete(); yield break; } //网络版本高于或者等于本地版本,则检查更新 _versions = Versions.LoadVersions(_savePath + Versions.Filename, true); if (_versions.Count > 0) { PrepareDownloads(); _step = Step.Prepared; } else { OnComplete(); } } catch (Exception e) { Debug.LogException(e); MessageBox.Show("提示", "版本文件加载失败", "重试", "退出").onComplete += delegate(MessageBox.EventId id) { if (id == MessageBox.EventId.Ok) { StartUpdate(); } else { Quit(); } }; } }