Beispiel #1
0
 protected virtual void DoProcess(
     RuntimePlatform platform,
     BuildTarget target,
     IBundleBuildConfig settings,
     ABBuildResult result,
     IList <IBundleFileManifest> bundleList)
 {
 }
Beispiel #2
0
 public void OnProcess(
     RuntimePlatform platform,
     BuildTarget target,
     IBundleBuildConfig settings,
     ABBuildResult result,
     IList <IBundleFileManifest> bundleList)
 {
     using (var scope = new CalcProcessTimerScope(this.GetType().Name))
     {
         DoProcess(platform, target, settings, result, bundleList);
     }
 }
Beispiel #3
0
        //============================================
        //	関数
        //============================================

        /// <summary>
        /// ビルド
        /// </summary>
        public virtual ABBuildResult Build(RuntimePlatform platform, BuildTarget target)
        {
            Context = new BuildContext();
            PreProcess?.SetContext(Context);
            BuildProcess?.SetContext(Context);
            PostProcess?.SetContext(Context);

            //  ビルド対象アセットの絞り込み
            IReadOnlyList <string> buildAssets = null;

            using (var timer = new CalcProcessTimerScope("Filter Assets"))
            {
                buildAssets = FileCollection.GetFiles();;
            }
            IList <IBundlePackRule> packageGroup = null;

            using (var timer = new CalcProcessTimerScope("CreatePackageList"))
            {
                packageGroup = RuleBuilder.GetPackRuleList();
            }
            //	ビルドマップの生成
            IList <IBundleFileManifest> assetBundleList = null;

            using (var timer = new CalcProcessTimerScope("Build BundleList"))
            {
                assetBundleList = Calclater.CreatePackageList(Config, buildAssets, packageGroup);
            }
            //  事前処理
            using (var timer = new CalcProcessTimerScope("Run PreProcess"))
            {
                PreProcess?.OnProcess(platform, target, Config, assetBundleList);
            }
            //	ビルド実行
            ABBuildResult result = default;

            using (var timer = new CalcProcessTimerScope("Run Build Process"))
            {
                result = BuildProcess.Build(platform, target, Config, assetBundleList);
            }
            using (var timer = new CalcProcessTimerScope("Run Post Process"))
            {
                //	事後処理
                PostProcess?.OnProcess(platform, target, Config, result, assetBundleList);
            }

            AssetDatabase.Refresh();

            return(result);
        }
Beispiel #4
0
 protected override void DoProcess(RuntimePlatform platform, BuildTarget target, IBundleBuildConfig settings, ABBuildResult result, IList <IBundleFileManifest> bundleList)
 {
     for (int i = 0; i < m_processes.Length; i++)
     {
         var process = m_processes[i];
         process.OnProcess(platform, target, settings, result, bundleList);
     }
 }
Beispiel #5
0
        protected override void DoProcess(RuntimePlatform platform, UnityEditor.BuildTarget target, IBundleBuildConfig settings, ABBuildResult result, IList <IBundleFileManifest> bundleList)
        {
            var outputPath = OutputPath.Get(platform);
            var list       = bundleList.OrderBy(c => c.ABName).ToArray();
            var manifest   = result.Manifest;
            var packResult = new StringBuilder();

            packResult.AppendLine("[Bundle List]");
            using (var scope = new ProgressDialogScope("Bundle List", list.Length * 2))
            {
                for (int i = 0; i < list.Length; i++)
                {
                    packResult.AppendLine(list[i].ABName);
                }
                packResult.AppendLine("=============================");
                for (int i = 0; i < list.Length; i++)
                {
                    var bundle = list[i];
                    scope.Show(bundle.ABName, i);
                    AppendDependencies(packResult, bundle, manifest);
                }
            }
            var assetsList = new StringBuilder();

            // Bundle List
            assetsList.AppendLine("[Bundle Assets dependencies]");
            using (var scope = new ProgressDialogScope("Bundle Assets List", list.Length))
            {
                for (int i = 0; i < list.Length; i++)
                {
                    var d = bundleList[i];
                    assetsList.AppendFormat("{0} : {1}", i + 1, d.ABName)
                    .AppendLine();
                    scope.Show(d.ABName, i);
                    foreach (var path in d.Assets)
                    {
                        assetsList
                        .Append("    ")
                        .AppendFormat("{0}", path)
                        .AppendLine();
                    }
                }
            }
            if (Directory.Exists(outputPath.BasePath))
            {
                Directory.CreateDirectory(outputPath.BasePath);
            }
            var resultContents = new[]
            {
                new { name = nameof(packResult), content = packResult },
                new { name = nameof(assetsList), content = assetsList },
            };

            foreach (var c in resultContents)
            {
                var filePath = outputPath.ToLocation(c.name + ".txt");
                File.WriteAllText(filePath.FullPath, c.content.ToString());
            }
        }
Beispiel #6
0
        //=========================================
        //  関数
        //=========================================

        /// <summary>
        /// ビルドマップを作成
        /// </summary>
        protected override void DoProcess(RuntimePlatform platform, BuildTarget target, IBundleBuildConfig settings, ABBuildResult result, IList <IBundleFileManifest> bundleList)
        {
            var json            = new BuildMapDataTable();
            var buildMapFile    = m_buildMapPath.Get(platform);
            var bundleDirectory = OutputPath.Get(platform);

            //	外部情報
            var manifest = result.Manifest;
            var prefix   = settings.TargetDirPath;

            json.Prefix = prefix;
            var table = bundleList.ToDictionary(c => c.ABName, c => c.Identifier);

            using (var scope = new ProgressDialogScope("Create Bundle Manifest : " + buildMapFile, bundleList.Count))
            {
                //	テーブル作成
                for (int i = 0; i < bundleList.Count; i++)
                {
                    //	BuildFileData
                    var fileData = bundleList[i];
                    //	Path
                    var file = bundleDirectory.ToLocation(fileData.ABName);
                    //	Create BuildMap Data
                    var d = CreateBuildData(file, fileData, table, manifest);
                    scope.Show(fileData.ABName, i);
                    json.Add(d);
                }
            }
            var addresses = bundleList
                            .SelectMany(c => c.Address)
                            .Distinct()
                            .ToArray();

            using (var scope = new ProgressDialogScope("Create Asset Table : " + buildMapFile, addresses.Length))
            {
                for (int i = 0; i < addresses.Length; i++)
                {
                    var address = addresses[i];
                    var path    = address.StartsWith(prefix) ? address : prefix + address;
                    var d       = new AssetBuildData
                    {
                        Path = address,
                        Guid = AssetDatabase.AssetPathToGUID(path)
                    };
                    scope.Show(address, i);
                    json.Add(d);
                }
            }
            var builder = m_builder.Build();

            builder.Write(buildMapFile.FullPath, json);
        }
Beispiel #7
0
        /// <summary>
        /// 実行
        /// </summary>
        protected override void DoProcess(RuntimePlatform platform, BuildTarget target, IBundleBuildConfig settings, ABBuildResult result, IList <IBundleFileManifest> bundleList)
        {
            //	親ディレクトリ
            var rootDirPath = OutputPath.Get(platform);

            if (!Directory.Exists(rootDirPath.BasePath))
            {
                Debug.LogWarning($"OutputDir is Not Exists : { rootDirPath}");
                return;
            }

            //	ファイル一覧
            var fileList = Directory.EnumerateFiles(
                path: rootDirPath.BasePath,
                searchPattern: settings.GetBundleName("*"),
                searchOption: SearchOption.AllDirectories
                )
                           .Select(c => c.Replace("\\", "/"))
                           .OrderBy(c => c)
                           .ToList();

            // 出力結果にあるものは除外していく
            foreach (var ab in bundleList)
            {
                var abPath = rootDirPath.ToLocation(ab.ABName);
                if (File.Exists(abPath.FullPath))
                {
                    fileList.Remove(abPath.FullPath);
                }
            }

            var builder = new StringBuilder();

            //	不要になったファイルを削除
            foreach (var f in fileList)
            {
                builder.AppendLine($"delete :: {f}");
                SafeDelete(f);
                SafeDelete(f + ".manifest");
            }
            File.WriteAllText(rootDirPath.ToLocation("delete-log.txt").FullPath, builder.ToString(), new UTF8Encoding(false));
        }