private static void ProcessPackage(string workingPath, string tempworkingPath, string packagePath, AssetBundleBuildRule.Platform platform) { AssetBundleFileDatas.Clear(); string packageVersionPath = $"{packagePath}{AppConst.AssetBundleConfig.VersionFile}"; string assetbundleZipPath = $"{packagePath}{AppConst.AssetBundleConfig.AssetBundlePackageFile}"; string fileInfoPath = $"{packagePath}{AppConst.AssetBundleConfig.FileListFile}"; string[] allFiles = Directory.GetFiles(workingPath, "*", SearchOption.AllDirectories); List <string> allAssetBundleFiles = new List <string>(); foreach (string tempFile in allFiles) { string path = tempFile.Replace("\\", "/"); if (Path.GetExtension(path) == ".manifest") { continue; } allAssetBundleFiles.Add(path); } EditorUtility.ClearProgressBar(); int index = 0; int count = allAssetBundleFiles.Count; long sizeCount = 0; foreach (string assetBundleFile in allAssetBundleFiles) { index++; EditorUtility.DisplayProgressBar("复制AssetBundle", "复制AssetBundle文件", (float)index / (float)count); string target = assetBundleFile.Replace(workingPath, tempworkingPath); string targetPath = Path.GetDirectoryName(target); if (!Directory.Exists(targetPath)) { if (targetPath != null) { Directory.CreateDirectory(targetPath); } } File.Copy(assetBundleFile, target); AssetBundleFileData assetBundleFileData = new AssetBundleFileData(); byte[] srcBytes = File.ReadAllBytes(assetBundleFile); int srcLength = srcBytes.Length; sizeCount += srcBytes.Length; byte[] srcMd5Bytes = MD5Utility.GetMd5Bytes(srcBytes); int srcMd5Code = BitConverter.ToInt32(srcMd5Bytes, 0); string assetBundleName = target.Replace(tempworkingPath, ""); assetBundleFileData.AssetBundleName = assetBundleName; assetBundleFileData.Length = srcLength; assetBundleFileData.Md5Code = srcMd5Code; assetBundleFileData.ZipLength = 0; assetBundleFileData.ZipMd5Code = 0; AssetBundleFileDatas.Add(assetBundleFileData); } EditorUtility.ClearProgressBar(); ZipUtility.CompressFolder(assetbundleZipPath, tempworkingPath, "*", AssetBundleRule.ZipPassWord); using (ByteBuffer buffer = new ByteBuffer()) { ValueParse.WriteValue(buffer, platform.ToString(), ValueParse.StringParse); ValueParse.WriteValue(buffer, CurrentVersion.MasterVersion, ValueParse.IntParse); ValueParse.WriteValue(buffer, CurrentVersion.MinorVersion, ValueParse.IntParse); ValueParse.WriteValue(buffer, CurrentVersion.RevisedVersion, ValueParse.IntParse); ValueParse.WriteValue(buffer, allAssetBundleFiles.Count, ValueParse.IntParse); ValueParse.WriteValue(buffer, sizeCount, ValueParse.LongParse); ValueParse.WriteValue(buffer, string.IsNullOrEmpty(AssetBundleRule.AssetBundleVariant) ? "" : AssetBundleRule.AssetBundleVariant, ValueParse.StringParse); ValueParse.WriteValue(buffer, AssetBundleRule.ZipSelected, ValueParse.BoolParse); ValueParse.WriteValue(buffer, string.IsNullOrEmpty(AssetBundleRule.ZipPassWord) ? "" : AssetBundleRule.ZipPassWord, ValueParse.StringParse); File.WriteAllBytes(packageVersionPath, buffer.ToBytes()); } using (ByteBuffer buffer = new ByteBuffer()) { ValueParse.WriteValue(buffer, AssetBundleFileDatas.Count, ValueParse.IntParse); foreach (AssetBundleFileData assetBundleFileData in AssetBundleFileDatas) { ValueParse.WriteValue(buffer, assetBundleFileData.AssetBundleName, ValueParse.StringParse); ValueParse.WriteValue(buffer, assetBundleFileData.Length, ValueParse.IntParse); ValueParse.WriteValue(buffer, assetBundleFileData.Md5Code, ValueParse.IntParse); ValueParse.WriteValue(buffer, assetBundleFileData.ZipLength, ValueParse.IntParse); ValueParse.WriteValue(buffer, assetBundleFileData.ZipMd5Code, ValueParse.IntParse); } File.WriteAllBytes(fileInfoPath, buffer.ToBytes()); } }