//检查版本信息 public void BeginInit(string remotoURL, Action<Exception> onInit, IEnumerable<string> groups, int taskcount = 1, bool checkRemote = true) { this.remoteurl = remotoURL; this.taskCount = taskcount; verLocal = new LocalVersion(); Action<Exception> onInitRemote = (err) => { if (err != null) { onInit(err); return; } Debug.Log("(ver)onInitRemote"); //检查需更新的列表 int addcount = 0; int updatecount = 0; verLocal.ver = this.verRemote.ver; foreach (var g in groups) { if (verLocal.groups.ContainsKey(g) == false) { if (verRemote.groups.ContainsKey(g) == false) { Debug.LogWarning("group:" + g + " 在服务器和本地均不存在"); continue; } else { verLocal.groups[g] = new LocalVersion.VerInfo(g, "", 0); } } verLocal.groups[g].groupfilecount = this.verRemote.groups[g].filecount; verLocal.groups[g].grouphash = this.verRemote.groups[g].hash; verLocal.groups[g].listverid = this.verRemote.ver; //Debug.Log("check groups=====================>" + g); foreach (var f in verRemote.groups[g].files) { //Debug.Log("check files=====>" + f.Key); if (verLocal.groups[g].listfiles.ContainsKey(f.Key)) { var fl = verLocal.groups[g].listfiles[f.Key]; if (fl.hash != f.Value.hash || fl.size != f.Value.length) { // fl.state |= LocalVersion.ResState.ResState_NeedUpdate; fl.needupdate = true; updatecount++; Debug.Log("(ver)update:" + f.Key); } } else { Debug.Log("(ver)add:" + f.Key); verLocal.groups[g].listfiles[f.Key] = new LocalVersion.ResInfo(g, f.Key, f.Value.hash, f.Value.length); verLocal.groups[g].listfiles[f.Key].state = LocalVersion.ResState.ResState_UseRemote; verLocal.groups[g].listfiles[f.Key].needupdate = true; addcount++; } } } Debug.Log("(ver)addcount:" + addcount + ",updatecount:" + updatecount); verLocal.Save(groups); onInit(null); }; Action onInitLocal = () => { Debug.Log("(ver)onInitLocal"); //此处仅完成本地资源检查,如果需要服务器同步,调用BeginCheckRemote if (!checkRemote) { onInit(null); } else { //taskState.Clear(); verRemote = new RemoteVersion(); verRemote.BeginInit(onInitRemote, groups); } }; verLocal.BeginInit(onInitLocal, groups); //01先尝试从存储位置初始化Verinfo,没有则从Streaming assets 初始化本地Verinfo //02从服务器下载总的资料 //03完成后回调 }