public static FileMapSystem CreateFromPersistAssetFile(string Dir) { var FileMap = new FileMapSystem(Dir); var bs = UnityPersistFileHelper.ReadPersistAssetFileAllBytes(Dir, FileMap.FileMapInfoFileName); if (bs == null || bs.Length == 0) { return(null); } FileMap.InitFileMapInfo(bs); return(FileMap); }
public static FileMapSystem CreateFromStreamAssetFile(string Dir) { var FileMap = new FileMapSystem(Dir); var bs = UnityStreamingFileHelper.ReadStreamAssetFileAllBytes(Dir, FileMap.FileMapInfoFileName); if (bs == null || bs.Length == 0) { //Debug.LogError("本地读取到数据长度为0,Dir:"+Dir); return(null); } FileMap.InitFileMapInfo(bs); //Debug.LogError("初始化Map成功,len:"+bs.Length+"Dir:"+Dir); return(FileMap); }
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 versionFilePath = _tempDownloadPath + VersionInfoFileName; var singleFileDownloadRequest = new SingleFileDownloadRequest(); singleFileDownloadRequest.Reset(GetDownloadURL(VersionInfoFileName), versionFilePath); yield return(DownloadSingleFile(singleFileDownloadRequest)); if (!singleFileDownloadRequest.success) { yield break; } VersionInfo versionInfo; try { var versionFileStr = File.ReadAllText(versionFilePath); versionInfo = versionFileStr.FromXML <VersionInfo>(); } catch (Exception e) { CommonLog.Error(e.Message); MessageBox.Show("提示", "版本文件加载失败", "重试", "退出").onComplete += delegate(MessageBox.EventId id) { if (id == MessageBox.EventId.Ok) { StartUpdate(); } else { Quit(); } }; yield break; } var state = versionInfo.CheckUpdateState(AssetBundleManager.Instance.GetVersion()); _currentTargetVersion = versionInfo; var versionStr = versionInfo.DumpVersion(); CommonLog.Log(MAuthor.WY, $"check version {versionStr} result {state}"); if (state == VersionInfo.State.NeedUpdate) { //下载xmf var xmfFileName = AssetBundlePathResolver.BundleSaveDirName + FileMapGroupInfo.FileExtension; var xmfTargetPath = _tempDownloadPath + xmfFileName; singleFileDownloadRequest.Reset(GetDownloadURL(xmfFileName, versionStr), xmfTargetPath, new MD5Creater.MD5Struct { MD51 = versionInfo.AssetBundlesCacheXmfMd51, MD52 = versionInfo.AssetBundlesCacheXmfMd52 }); yield return(DownloadSingleFile(singleFileDownloadRequest)); if (!singleFileDownloadRequest.success) { yield break; } //下载AssetBundleXMLData.xml var xmlPath = _tempDownloadPath + AssetBundlePathResolver.DependFileName; singleFileDownloadRequest.Reset( GetDownloadURL(AssetBundlePathResolver.DependFileName, versionStr), xmlPath, new MD5Creater.MD5Struct { MD51 = versionInfo.AssetBundleXmlMd51, MD52 = versionInfo.AssetBundleXmlMd52 }); yield return(DownloadSingleFile(singleFileDownloadRequest)); if (!singleFileDownloadRequest.success) { yield break; } var tableStr = File.ReadAllText(xmlPath); _currentDownloadAssetBundleTable = tableStr.FromXML <AssetBundleTable>(); var newFileMap = new FileMapSystem.FileMapSystem(_tempDownloadPath); var bs = File.ReadAllBytes(xmfTargetPath); newFileMap.InitFileMapInfo(bs); PrepareDownloads(newFileMap, versionStr); _step = Step.Prepared; } else { switch (state) { case VersionInfo.State.MustDownloadAppAgain: { #if UNITY_ANDROID ShowAndroidUpdateDialog(versionInfo.AppUpdateUrl); yield break; #elif UNITY_IOS ShowIOSUpdateDialog(versionInfo.AppUpdateUrl); yield break; #else var mb = MessageBox.Show("提示", $"需要重新下载app"); yield return(mb); Quit(); #endif break; } case VersionInfo.State.NotNeedUpdate: { OnComplete(); break; } } } }