예제 #1
0
        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} 个"));
        }
예제 #2
0
        void DoPublish()
        {
            if (string.IsNullOrEmpty(mPatchPath))
            {
                ShowNotification(new GUIContent("补丁路径不能为空"));
                return;
            }

            if (!Directory.Exists(mPatchPath))
            {
                ShowNotification(new GUIContent("补丁路径不存在:" + mPatchPath));
                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 tmpVideoFolder        = PathHelper.GetBytesFileFoldNameByType(PathHelper.EBytesFileType.Video);                   //源资源video文件夹

            string tmpPublishResourcesPath = Application.dataPath.Replace("\\", "/") + "/Publish/Resources/";                        //发布存放.bytes的目录
            string tmpStreamingAssetsPath  = Application.streamingAssetsPath.Replace("\\", "/") + "/";                               //发布存放bundle的路径
            string tmpPatchPath            = mPatchPath + mPlatform + "/All_" + System.DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss"); //当前补丁存放路径

            if (!Directory.Exists(tmpPatchPath))
            {
                Directory.CreateDirectory(tmpPatchPath);
            }

            if (!Directory.Exists(tmpPublishResourcesPath))
            {
                Directory.CreateDirectory(tmpPublishResourcesPath);
            }

            if (!Directory.Exists(tmpStreamingAssetsPath))
            {
                Directory.CreateDirectory(tmpStreamingAssetsPath);
            }

            PublishUtility.DeleteAllFile(tmpPublishResourcesPath);
            PublishUtility.DeleteAllFile(tmpStreamingAssetsPath);

            //把bundle文件对应平台文件copy一份到StreamingAssets
            List <ResouceElement> tmpStreamingAssetsList = PublishUtility.GetResouceElements(tmpBundlePath, ResouceElement.EResType.AssetBundle, string.Empty);

            PublishUtility.CopyRes2Path(tmpStreamingAssetsList, tmpStreamingAssetsPath, string.Empty);
            PublishUtility.CopyRes2Path(tmpStreamingAssetsList, tmpPatchPath, string.Empty);

            //处理tbl
            List <ResouceElement> tmpTblList = PublishUtility.GetResouceElements($"{tmpRuntimeResFullPath}/{tmpTblFolder}", ResouceElement.EResType.Bytes, tmpTblFolder);

            PublishUtility.CopyRes2Path(tmpTblList, tmpPublishResourcesPath, ".bytes");
            PublishUtility.CopyRes2Path(tmpTblList, tmpPatchPath, string.Empty);

            //游戏动作
            List <ResouceElement> tmpActionList = PublishUtility.GetResouceElements($"{tmpRuntimeResFullPath}/{tmpSkillActionFolder}", ResouceElement.EResType.Bytes, tmpSkillActionFolder);

            PublishUtility.CopyRes2Path(tmpActionList, tmpPublishResourcesPath, ".bytes");
            PublishUtility.CopyRes2Path(tmpActionList, tmpPatchPath, string.Empty);

            //录像
            List <ResouceElement> tmpVideoList = PublishUtility.GetResouceElements($"{tmpRuntimeResFullPath}/{tmpVideoFolder}", ResouceElement.EResType.Bytes, tmpVideoFolder);

            PublishUtility.CopyRes2Path(tmpVideoList, tmpPublishResourcesPath, ".bytes");
            PublishUtility.CopyRes2Path(tmpVideoList, tmpPatchPath, string.Empty);


            //#if UNITY_EDITOR
            //            Process.Start("Explorer.exe", tmpPatchPath.Replace("/", "\\"));
            //#endif

            List <ResouceElement> tmpAllResList = new List <ResouceElement>();

            tmpAllResList.AddRange(tmpStreamingAssetsList);
            tmpAllResList.AddRange(tmpTblList);
            tmpAllResList.AddRange(tmpActionList);
            tmpAllResList.AddRange(tmpVideoList);

            uint tmpVersionFileCrc = FileHelper.ResVersionFileCRC;
            uint tmpResDescFileCrc = 0;

            PublishUtility.GenResDescAndVersionFile(tmpPatchPath, tmpAllResList, FileHelper.RES_DESC_FILE, out tmpResDescFileCrc,
                                                    tmpVersionFileCrc, mMajor, mMinor, mSvn, tmpPublishResourcesPath);
            PublishUtility.GenAssistDescFile(tmpAllResList, tmpPatchPath, $"{mMajor}.{mMinor}.{mSvn}", tmpVersionFileCrc.ToString(), tmpResDescFileCrc.ToString());

            ShowNotification(new GUIContent("打包成功"));

            AssetDatabase.Refresh();
        }