public async Task StartAsync() { using (UnityWebRequestAsync request = ComponentFactory.Create <UnityWebRequestAsync>()) { string versionUrl = GlobalConfigComponent.Instance.GlobalProto.GetUrl() + "StreamingAssets/" + "Version.txt"; Log.Debug(versionUrl); await request.DownloadAsync(versionUrl); this.VersionConfig = MongoHelper.FromJson <VersionConfig>(request.Request.downloadHandler.text); } Log.Debug("WebVersion:\n" + MongoHelper.ToJson(this.VersionConfig)); // 对比本地的Version.txt string versionPath = Path.Combine(PathHelper.AppHotfixResPath, "Version.txt"); if (!File.Exists(versionPath)) { foreach (FileVersionInfo versionInfo in this.VersionConfig.FileVersionInfos) { if (versionInfo.File == "Version.txt") { continue; } this.bundles.Enqueue(versionInfo.File); this.TotalSize += versionInfo.Size; } } else { VersionConfig localVersionConfig = MongoHelper.FromJson <VersionConfig>(File.ReadAllText(versionPath)); Log.Debug("LocalVersion:\n" + MongoHelper.ToJson(localVersionConfig)); // 先删除服务器端没有的ab foreach (FileVersionInfo fileVersionInfo in localVersionConfig.FileVersionInfos) { if (this.VersionConfig.FileInfoDict.ContainsKey(fileVersionInfo.File)) { continue; } string abPath = Path.Combine(PathHelper.AppHotfixResPath, fileVersionInfo.File); File.Delete(abPath); } // 再下载 foreach (FileVersionInfo fileVersionInfo in this.VersionConfig.FileVersionInfos) { FileVersionInfo localVersionInfo; if (localVersionConfig.FileInfoDict.TryGetValue(fileVersionInfo.File, out localVersionInfo)) { if (fileVersionInfo.MD5 == localVersionInfo.MD5) { continue; } } if (fileVersionInfo.File == "Version.txt") { continue; } this.bundles.Enqueue(fileVersionInfo.File); this.TotalSize += fileVersionInfo.Size; } } if (this.bundles.Count == 0) { return; } Log.Debug($"need download bundles: {this.bundles.ToList().ListToString()}"); await this.WaitAsync(); }
public static string ToJson(object obj) { return(MongoHelper.ToJson(obj)); }
public void Awake() { string s = File.ReadAllText("./ClientConfig.txt"); this.Config = MongoHelper.FromJson <ClientConfig>(s); }
public static T FromJson <T>(string str) { return(MongoHelper.FromJson <T>(str)); }
public static object FromJson(Type type, string str) { return(MongoHelper.FromJson(type, str)); }
public object DeserializeFrom(Type type, string str) { return(MongoHelper.FromJson(type, str)); }
public object DeserializeFrom(Type type, byte[] bytes, int index, int count) { return(MongoHelper.FromBson(type, bytes, index, count)); }
public override string ToString() { return(MongoHelper.ToJson(this)); }
public object Clone() { return(MongoHelper.FromJson(this.GetType(), this.ToString())); }
public byte[] SerializeToByteArray(object obj) { return(MongoHelper.ToBson(obj)); }
public object Clone() { return(MongoHelper.FromBson(this.GetType(), this.ToBson())); }
public T DeserializeFrom <T>(string str) { return(MongoHelper.FromJson <T>(str)); }
public T DeserializeFrom <T>(byte[] bytes, int index, int count) { return(MongoHelper.FromBson <T>(bytes, index, count)); }
public T DeserializeFrom <T>(byte[] bytes) { return(MongoHelper.FromBson <T>(bytes)); }
public string SerializeToText(object obj) { return(MongoHelper.ToJson(obj)); }
private void Awake() { string s = File.ReadAllText("../Config/StartConfig/ClientConfig.txt"); this.Config = MongoHelper.FromJson <StartConfig>(s); }
public T DeserializeFrom <T>(string str) where T : SerializerBinary { return(MongoHelper.FromJson <T>(str)); }
public object Clone() { return(MongoHelper.FromJson <StartConfig>(MongoHelper.ToJson(this))); }
public object Clone() { return(MongoHelper.FromBson <Options>(this.ToBson())); }
public object DeserializeFrom(Type type, byte[] bytes) { return(MongoHelper.FromBson(type, bytes)); }