void DoPublish() { if (string.IsNullOrEmpty(mLastPatchPath) || !Directory.Exists(mLastPatchPath) || string.IsNullOrEmpty(mCurrPatchPath) || !Directory.Exists(mCurrPatchPath)) { ShowNotification(new GUIContent("错误:路径为空或不存在此路径")); return; } string tmpRuntimeResFullPath = Path.GetFullPath(PathHelper.RUN_TIME_RES_PATH).Replace("\\", "/"); string tmpBundlePath = $"{tmpRuntimeResFullPath}/{string.Format(PathHelper.BUNDLE_FOLDER, mPlatform)}/"; //源资源bundle路径 string tmpTblFolder = PathHelper.GetBytesFileFoldNameByType(PathHelper.EBytesFileType.Table); //源资源tbl文件夹 string tmpSkillActionFolder = PathHelper.GetBytesFileFoldNameByType(PathHelper.EBytesFileType.Action); //源资源SkillAction文件夹 string tmpPatchPath = mCurrPatchPath + mPlatform + "/Patch_" + System.DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss"); //当前补丁存放路径 if (!Directory.Exists(tmpPatchPath)) { Directory.CreateDirectory(tmpPatchPath); } //把bundle文件对应平台文件copy一份到StreamingAssets List <ResouceElement> tmpStreamingAssetsList = PublishUtility.GetResouceElements(tmpBundlePath, ResouceElement.EResType.AssetBundle, string.Empty); //处理tbl List <ResouceElement> tmpTblList = PublishUtility.GetResouceElements($"{tmpRuntimeResFullPath}/{tmpTblFolder}", ResouceElement.EResType.Bytes, tmpTblFolder); //游戏动作 List <ResouceElement> tmpActionList = PublishUtility.GetResouceElements($"{tmpRuntimeResFullPath}/{tmpSkillActionFolder}", ResouceElement.EResType.Bytes, tmpSkillActionFolder); List <ResouceElement> tmpAllResList = new List <ResouceElement>(); tmpAllResList.AddRange(tmpStreamingAssetsList); tmpAllResList.AddRange(tmpTblList); tmpAllResList.AddRange(tmpActionList); uint tmpVersionFileCrc = FileHelper.ResVersionFileCRC; uint tmpResDescFileCrc = 0; PublishUtility.GenResDescAndVersionFile(tmpPatchPath, tmpAllResList, FileHelper.RES_DESC_FILE, out tmpResDescFileCrc, tmpVersionFileCrc, mMajor, mMinor, mSvn); //差异比较 string tmpPath = $"{mLastPatchPath}/{FileHelper.ResVersionFileCRC}"; if (!File.Exists(tmpPath)) { ShowNotification(new GUIContent($"错误:找不到最后一次补丁的版本描述文件 {FileHelper.ResVersionFileCRC}")); return; } byte[] tmpData = FileHelper.ReadFile(tmpPath); VersionData tmpLastVersionData = VersionData.LoadVersionData(tmpData); tmpPath = $"{mLastPatchPath}/{tmpLastVersionData.ResDescCrc}"; if (!File.Exists(tmpPath)) { ShowNotification(new GUIContent($"错误:找不到最后一次补丁的资源描述文件 {tmpLastVersionData.ResDescCrc}")); return; } tmpData = FileHelper.ReadFile(tmpPath); Dictionary <uint, long> tmpLastResDescInfo = ResourcesSystem.LoadResDescInfo(tmpData); List <ResouceElement> tmpDiffList = new List <ResouceElement>(); for (int i = 0, max = tmpAllResList.Count; i < max; ++i) { ResouceElement tmpResElem = tmpAllResList[i]; long tmpResFlag = 0; if (tmpLastResDescInfo.TryGetValue(tmpResElem.keyHash, out tmpResFlag)) { var tmpResInfo = ResourcesSystem.ResFlag2Info(tmpResFlag); if (tmpResElem.fileHash == tmpResInfo.FileHash) { continue; } } tmpDiffList.Add(tmpResElem); } PublishUtility.GenAssistDescFile(tmpDiffList, tmpPatchPath, $"{mMajor}.{mMinor}.{mSvn}", tmpVersionFileCrc.ToString(), tmpResDescFileCrc.ToString()); PublishUtility.CopyRes2Path(tmpDiffList, tmpPatchPath, string.Empty); ShowNotification(new GUIContent($"打包补丁成功 差异化文件 {tmpDiffList.Count} 个")); }