public static IEnumerator Package(List <EditPackageConfig> relyPackages, List <EditPackageConfig> bundles, PackageCallBack callBack) { BuildPipeline.PushAssetDependencies(); float sumCount = relyPackages.Count + bundles.Count; float currentCount = 0; callBack(0, "删除旧资源"); yield return(0); //删除streaming下所有旧资源 if (Directory.Exists(Application.dataPath + "/StreamingAssets")) { FileTool.DeleteDirectory(Application.dataPath + "/StreamingAssets"); } callBack(0, "开始打包"); yield return(0); //先打依赖包 for (int i = 0; i < relyPackages.Count; i++) { PackageRelyPackage(relyPackages[i]); currentCount++; callBack(currentCount / sumCount, "打包依赖包 第" + i + "个 共" + relyPackages.Count + "个"); yield return(0); } //再打普通包 for (int i = 0; i < bundles.Count; i++) { PackageBundle(bundles[i]); currentCount++; callBack(currentCount / sumCount, "打包普通包 第" + i + "个 共" + bundles.Count + "个"); yield return(0); } BuildPipeline.PopAssetDependencies(); AssetDatabase.Refresh(); }
#pragma warning disable public static IEnumerator Package(List <EditPackageConfig> relyPackages, List <EditPackageConfig> bundles, PackageCallBack callBack) { relyBuildOption = BuildAssetBundleOptions.DeterministicAssetBundle //每次二进制一致 | BuildAssetBundleOptions.CollectDependencies //收集依赖 | BuildAssetBundleOptions.CompleteAssets; //完整资源 //| BuildAssetBundleOptions.UncompressedAssetBundle //不压缩 BuildPipeline.PushAssetDependencies(); float sumCount = relyPackages.Count + bundles.Count; float currentCount = 0; callBack(0, "删除旧资源"); yield return(0); //删除streaming下所有旧资源 if (Directory.Exists(Application.dataPath + "/StreamingAssets")) { FileTool.DeleteDirectory(Application.dataPath + "/StreamingAssets"); } callBack(0, "开始打包"); yield return(0); //先打依赖包 for (int i = 0; i < relyPackages.Count; i++) { PackageRelyPackage(relyPackages[i]); currentCount++; callBack(currentCount / sumCount, "打包依赖包 第" + i + "个 共" + relyPackages.Count + "个"); yield return(0); } //再打普通包 for (int i = 0; i < bundles.Count; i++) { PackageBundle(bundles[i]); currentCount++; callBack(currentCount / sumCount, "打包普通包 第" + i + "个 共" + bundles.Count + "个"); yield return(0); } //for (int i = 0; i < m_NoPackagekFile.Count; i++) //{ // CopyFile(m_NoPackagekFile[i]); //} BuildPipeline.PopAssetDependencies(); AssetDatabase.Refresh(); }