public static async Task <LoaderRequest> Load(string rURL) { LoaderRequest rRequest = new LoaderRequest(rURL); string rVersionURL = rRequest.Url; WWWAssist.LoaderRequest rWWWVersionRequest = await WWWAssist.LoadFile(rVersionURL); if (rWWWVersionRequest.Bytes == null || rWWWVersionRequest.Bytes.Length == 0) { return(null); } ABVersion rVersion = new ABVersion(); using (var ms = new MemoryStream(rWWWVersionRequest.Bytes)) { using (var br = new BinaryReader(ms)) { rVersion.Deserialize(br); } } rRequest.Version = rVersion; return(rRequest); }
public IEnumerator Initialize() { GameLoading.Instance.StartLoading(1.0f, "游戏初始化阶段,开始检查资源更新..."); // 加载Streaming空间下的版本MD5码 var rStreamingMD5Request = WWWAssist.LoadFile(ABPlatform.Instance.GetStreamingUrl_CurPlatform(ABVersion.ABVersion_File_MD5)); yield return(rStreamingMD5Request); mStreamingMD5 = rStreamingMD5Request.Text; Debug.Log("--- Streaming MD5: " + mStreamingMD5); if (!ABPlatform.Instance.IsDevelopeMode()) { // 加载Persitent空间下的版本MD5码 var rPersistentMD5Request = WWWAssist.LoadFile(ABPlatform.Instance.GetPersistentUrl_CurPlatform(ABVersion.ABVersion_File_MD5)); yield return(rPersistentMD5Request); mPersistentMD5 = rPersistentMD5Request.Text; Debug.Log("--- Persistent MD5: " + mPersistentMD5); // 加载服务器上的版本MD5码 var rServerMD5Request = WebRequestAssist.DownloadFile(ABPlatform.Instance.GetServerUrl_CurPlatform(ABVersion.ABVersion_File_MD5)); yield return(rServerMD5Request); mServerMD5 = rServerMD5Request.Text; Debug.Log("--- Server MD5: " + mServerMD5); // 加载Persisntent空间的版本信息文件 var rPersistentVersionRequest = ABVersion.Load(ABPlatform.Instance.GetPersistentUrl_CurPlatform(ABVersion.ABVersion_File_Bin)); yield return(rPersistentVersionRequest); mPersistentVersion = rPersistentVersionRequest.Version; if (!string.IsNullOrEmpty(mServerMD5) && !mServerMD5.Equals(mPersistentMD5)) { GameLoading.Instance.Hide(); // 开始下载 yield return(this.UpdateResource_Sync()); } } GameLoading.Instance.StartLoading(0.2f, "游戏初始化阶段,开始加载资源..."); // 加载Streaming空间的版本信息文件 var rStreamingVersionRequest = ABVersion.Load(ABPlatform.Instance.GetStreamingUrl_CurPlatform(ABVersion.ABVersion_File_Bin)); yield return(rStreamingVersionRequest); mStreamingVersion = rStreamingVersionRequest.Version; // 生成最终用于资源加载的版本信息 this.GenerateCombineVersion(); GameLoading.Instance.Hide(); }
private static IEnumerator Load_Async(LoaderRequest rRequest) { string rVersionURL = rRequest.Url; WWWAssist.LoaderRequest rWWWVersionRequest = WWWAssist.LoadFile(rVersionURL); yield return(rWWWVersionRequest); if (rWWWVersionRequest.Bytes == null || rWWWVersionRequest.Bytes.Length == 0) { yield break; } ABVersion rVersion = new ABVersion(); using (var ms = new MemoryStream(rWWWVersionRequest.Bytes)) { using (var br = new BinaryReader(ms)) { rVersion.Deserialize(br); } } rRequest.Version = rVersion; }