/// <summary> /// 从安装目录拷贝文件到本地目录 /// </summary> IEnumerator StartCopyInitialFile(string local_name, System.Action <AssetBundleBatchCopy> callback) { if (copy_list_.Contains(local_name)) { yield break; } copy_list_.Add(local_name); StreamingAssetsCopy copy = new StreamingAssetsCopy(); yield return(copy.Copy(Common.GetInitialFileFullName(local_name), Common.GetFileFullName(local_name))); copy_list_.Remove(local_name); ++progress; if (callback != null) { callback(this); } if (copy.resultCode != emIOOperateCode.Succeed) { SetResult(true, copy.resultCode); } }
/// <summary> /// 初始化 /// </summary> IEnumerator Preprocess() { //创建资源根目录 if (!Directory.Exists(Common.PATH)) { Directory.CreateDirectory(Common.PATH); } //判断主资源文件是否存在,不存在则拷贝备份资源至资源根目录 bool do_initial_copy = false; string resources_manifest_file = Common.GetFileFullName(Common.RESOURCES_MANIFEST_FILE_NAME); if (!File.Exists(resources_manifest_file)) { do_initial_copy = true; } else { // 拷贝安装包初始化目录中的ResourcesManifest,并判断是否重新拷贝初始化目录下的所有文件 string full_name = Common.GetFileFullName(Common.RESOURCES_MANIFEST_FILE_NAME); string initial_full_name = Common.GetInitialFileFullName(Common.RESOURCES_MANIFEST_FILE_NAME); string cache_full_name = Common.GetCacheFileFullName(Common.RESOURCES_MANIFEST_FILE_NAME); yield return(Common.StartCopyFile(initial_full_name, cache_full_name)); //判断安装包初始目录是否完整 ResourcesManifest initial = Common.LoadResourcesManifestByPath(cache_full_name); if (initial == null) { Error(emErrorCode.PreprocessError , "Initial path don't contains " + Common.RESOURCES_MANIFEST_FILE_NAME + "!"); yield break; } ResourcesManifest current = Common.LoadResourcesManifestByPath(full_name); if (current == null) { do_initial_copy = true; } else if (current.Data.Version < initial.Data.Version) { do_initial_copy = true; } //删除缓存中的文件 if (File.Exists(cache_full_name)) { File.Delete(cache_full_name); } } if (do_initial_copy) { yield return(CopyAllInitialFiles()); } PreprocessFinished(); }