public void CreatResSetting() { resSetting = new ResSetting(); resSetting.manifestName = "ab"; GetFile(nowData.outpath); for (int i = 0; i < _files.Count; i++) { string file = _files[i]; EditorUtility.DisplayProgressBar("正在生成 res.json", string.Format("文件:{0}", file), ((float)i / resSetting.items.Count)); FileInfo fi = new FileInfo(file); if (fi.Extension == ".manifest" || fi.Extension == ".dll" || fi.Extension == ".pdb") { continue; } ABItem item = new ABItem(); item.name = _files[i].Replace(nowData.outpath, "").Replace("\\", "/"); item.version = GetMD5(_files[i]); item.size = fi.Length; resSetting.items.Add(item); } string u = FileTools.GetLocalPath("", "ResVersion.json");; string data = JsonMapper.ToJson(resSetting); ShowNotification(new GUIContent("生成配置完成")); File.WriteAllText(u, data); EditorUtility.ClearProgressBar(); }
public void Start(string sceneName) { pro = Object.FindObjectOfType(typeof(ProgressBar)) as ProgressBar; bool useLocalRes = Main.Instance.runtimeConfig.isUseLocalResourse; ResSetting res = FileTools.ReadText <ResSetting>(FileTools.GetLocalPath("", "ResVersion.json")); if (res == null) { res = new ResSetting(); } UpdateAB uab = new UpdateAB(res, FileTools.GetNetPath("")); uab.progress += Progress; uab.updateEnd += UpdateEnd; uab.Start(); Debug.Log("进入"); }
private IEnumerator LoadRes() { UnityWebRequest www = UnityWebRequest.Get(netUrl + resName); www.SendWebRequest(); while (www.isDone == false) { if (progress != null) { progress.Invoke(www.downloadProgress, resName); } Debug.Log(www.downloadProgress + "\n" + resName); yield return(new WaitForEndOfFrame()); } if (string.IsNullOrEmpty(www.error)) { netRes = JsonMapper.ToObject <ResSetting>(www.downloadHandler.text); res.manifestName = netRes.manifestName; List <ABItem> net = netRes.items; List <ABItem> local = res.items; needUpdate = new List <ABItem>(net.ToArray()); foreach (ABItem netab in net) { foreach (ABItem localab in local) { if (netab.name == localab.name && netab.version == localab.version) { if (FileTools.FileExist(localUrl + localab.name) == true) { needUpdate.Remove(netab); } } } } } yield return(null); CoroutineCentre.Instance.StartCoroutine(Update(needUpdate)); }
public UpdateAB(ResSetting res, string url) { this.netUrl = url; this.res = res; localUrl = FileTools.GetLocalPath("ab", ""); }