Exemplo n.º 1
0
        /// <summary>
        /// 打包资源
        /// </summary>
        public void BuildAssetbundles(BuildAssetBundleOptions rOptions)
        {
            List <AssetBundleBuild> rABBList = AssetbundleEntry_Building();

            string        rABPath  = GetPathPrefix_Assetbundle();
            DirectoryInfo rDirInfo = new DirectoryInfo(rABPath);

            if (!rDirInfo.Exists)
            {
                rDirInfo.Create();
            }

            var rOldABVersion = ABVersionEditor.Load(rABPath);
            var rOldMD5       = ABVersionEditor.GetMD5ForABVersion(rABPath);

            // 开始打包
            var rNewABManifest = BuildPipeline.BuildAssetBundles(rABPath, rABBList.ToArray(), rOptions, (BuildTarget)CurBuildPlatform);

            // 生成新的版本文件
            var rNewABVersion = ABVersionEditor.CreateVersion(rABPath, rOldABVersion, rNewABManifest);

            rNewABVersion.SaveInEditor(rABPath);

            var rNewMD5 = ABVersionEditor.GetMD5ForABVersion(rABPath);

            // 保存历史的版本记录
            if (!string.IsNullOrEmpty(rOldMD5) && !rOldMD5.Equals(rNewMD5))
            {
                rOldABVersion.SaveHistory(rABPath);
            }
            Debug.Log("资源打包完成!");
        }
Exemplo n.º 2
0
        public void Initialize(string rOutPath)
        {
            mEntries = new Dict <string, Entry>();

            string        rHistoryPath    = UtilTool.PathCombine(rOutPath, "History");
            DirectoryInfo rHistoryDirInfo = new DirectoryInfo(rHistoryPath);

            if (!rHistoryDirInfo.Exists)
            {
                return;
            }

            ABVersion rCurVersion = ABVersionEditor.Load(rOutPath);

            var rSubDirs = rHistoryDirInfo.GetDirectories();

            for (int i = 0; i < rSubDirs.Length; i++)
            {
                Entry rEntry = new Entry();
                rEntry.Path           = UtilTool.PathCombine(rHistoryPath, rSubDirs[i].Name, ABVersion.ABVersion_File_Bin);
                rEntry.Time           = rSubDirs[i].Name;
                rEntry.IncVer         = new ABVersion();
                rEntry.IncVer.Entries = new Dict <string, ABVersionEntry>();

                ABVersion rHistoryVersion = ABVersionEditor.Load(rSubDirs[i].FullName);

                // 比较两个版本
                foreach (var rPair in rCurVersion.Entries)
                {
                    var rAVEntry  = rPair.Value;
                    var rOldEntry = rHistoryVersion.GetEntry(rAVEntry.Name);
                    if (rOldEntry == null)  // 说明是新增的
                    {
                        rEntry.IncVer.Entries.Add(rAVEntry.Name, rAVEntry);
                    }
                    else
                    {
                        if (rOldEntry.Version != rAVEntry.Version)  // 版本不一致
                        {
                            rEntry.IncVer.Entries.Add(rAVEntry.Name, rAVEntry);
                        }
                    }
                }
                mEntries.Add(rEntry.Time, rEntry);
            }
        }