Ejemplo n.º 1
0
        /// <summary>
        /// アセットバンドル生成結果配列の作成
        /// </summary>
        public IList <IBundleFileManifest> CreatePackageList(
            IBundleBuildConfig config,
            IReadOnlyList <string> buildAssets,
            IList <IBundlePackRule> packageConfigList
            )
        {
            var packageTable  = new Dictionary <string, IBundleFileManifest>();
            var buildAssetTmp = new List <string>(buildAssets);
            var packList      = packageConfigList.OrderBy(p => - p.Priority).ToArray();

            using (var scope = new ProgressDialogScope("Calclate Package", packList.Length))
            {
                for (var i = 0; i < packList.Length; i++)
                {
                    var pack = packList[i];
                    scope.Show(pack.Identifier, i);
                    var bundles = Package(config, pack, ref buildAssetTmp);

                    foreach (var b in bundles)
                    {
                        if (packageTable.ContainsKey(b.ABName))
                        {
                            packageTable[b.ABName].Merge(b);
                        }
                        else
                        {
                            packageTable.Add(b.ABName, b);
                        }
                    }
                }
            }
            return(packageTable.Values.ToArray());
        }
Ejemplo n.º 2
0
 //=================================
 // 関数
 //=================================
 public void OnProcess(RuntimePlatform platform, BuildTarget target, IBundleBuildConfig config, IList <IBundleFileManifest> bundleList)
 {
     using (var scope = new CalcProcessTimerScope(this.GetType().Name))
     {
         DoProcess(platform, target, config, bundleList);
     }
 }
Ejemplo n.º 3
0
 protected virtual void DoProcess(
     RuntimePlatform platform,
     BuildTarget target,
     IBundleBuildConfig settings,
     ABBuildResult result,
     IList <IBundleFileManifest> bundleList)
 {
 }
Ejemplo n.º 4
0
        protected IList <IBundleFileManifest> Package(IBundleBuildConfig config, IBundlePackRule pack, ref List <string> targetAssets)
        {
            //  パッケージ対象を抽出
            var packagedAssets = GetAssets(config, pack, targetAssets);

            //  パッケージ済みとして、残アセットから削除
            targetAssets.RemoveAll(p => packagedAssets.Contains(p));

            return(pack.Build(config, packagedAssets));
        }
Ejemplo n.º 5
0
        public override IBundleFileManifest Instantiate(IBundleBuildConfig config, IBundleGroup group, string[] labels)
        {
            var data = new ABBuildData
            {
                FolderPrefix = config.TargetDirPath,
                Identifier   = group.Identifier,
                ABName       = config.GetBundleName(group.Identifier),
                Assets       = group.Assets,
                Labels       = labels,
            };

            return(data);
        }
Ejemplo n.º 6
0
        protected virtual IBundleFileManifest Build(IBundleBuildConfig config, IBundleGroup group, BundlePackRule rule)
        {
            var data = new BundleBuildData
            {
                TopDirectoryPath = config.TargetDirPath,
                Identifier       = group.Identifier,
                ABName           = config.GetBundleName(group.Identifier),
                Assets           = group.Assets,
                Labels           = rule.Labels,
            };

            data.CalcAddress();
            return(data);
        }
Ejemplo n.º 7
0
 public override IList <IBundleGroup> GetGroupingAssets(IBundleBuildConfig config, IReadOnlyList <string> targetAssets)
 {
     return(targetAssets
            .GroupBy
                (c => Converter.Convert(c)
                .Replace(config.TargetDirPath, string.Empty)
                .ToLower()
                )
            .Select(c => new BundleGroup
     {
         Identifier = c.Key,
         Assets = c.ToArray()
     })
            .ToArray());
 }
Ejemplo n.º 8
0
        public virtual IList <IBundleGroup> GetGrouping(IBundleBuildConfig config, IBundleNameConverter converter, IReadOnlyList <string> packagedAssets)
        {
            var table  = new Dictionary <string, List <string> >();
            var prefix = config.TargetDirPath.ToConvertDelimiter().ToLower();

            foreach (var assetPath in packagedAssets)
            {
                var key = converter.Convert(assetPath).ToLower().Replace(prefix, string.Empty);
                if (!table.TryGetValue(key, out var list))
                {
                    list       = new List <string>();
                    table[key] = list;
                }
                list.Add(assetPath);
            }

            return(table.Select(item => Build(item.Key, item.Value)).ToArray());
        }
Ejemplo n.º 9
0
        //=========================================
        // Method
        //=========================================

        /// <summary>
        /// ビルド
        /// </summary>
        public virtual ABBuildResult Build(
            RuntimePlatform platform,
            BuildTarget target,
            IBundleBuildConfig settings,
            IList <IBundleFileManifest> assetBundleList
            )
        {
            var outputPath = m_outputPath.Get(platform);

            if (!Directory.Exists(outputPath.BasePath))
            {
                Directory.CreateDirectory(outputPath.BasePath);
            }

            var option     = settings.Options;
            var bundleList = assetBundleList
                             .Select(d => d.ToBuildEntry())
                             .ToArray();

            using (var scope = new CalcProcessTimerScope(this.GetType().Name))
            {
                return(DoBuild(platform, target, option, bundleList));
            }
        }
Ejemplo n.º 10
0
        //=====================================
        //	関数
        //=====================================

        /// <summary>
        /// 処理
        /// </summary>
        protected override void DoProcess(RuntimePlatform platform, BuildTarget target, IBundleBuildConfig config, IList <IBundleFileManifest> bundleList)
        {
            for (int i = 0; i < bundleList.Count; i++)
            {
                var data       = bundleList[i];
                var pathHash   = CalcPathHash(data);
                var bundleHash = CalcBundleHash(data);
                var identifier = data.Identifier;
                var path       = config.GetBundleName($"{bundleHash}/{pathHash}");
                // 更新
                //data.Apply(config.TargetDirPath, identifier, path, data.Assets);
            }
        }
Ejemplo n.º 11
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());
            }
        }
Ejemplo n.º 12
0
 public IReadOnlyList <string> GetAssets(IBundleBuildConfig config, IBundlePackRule pack, IReadOnlyList <string> targetAssets)
 {
     return(targetAssets
            .Where(p => pack.IsMatch(config.TargetDirPath, p))
            .ToList());
 }
Ejemplo n.º 13
0
        public override IList <IBundleFileManifest> CreatePackageList(IBundleBuildConfig config, IReadOnlyList <string> buildAssets, IList <IBundlePackRule> packageConfigList)
        {
            var calclater = new PackageCalclater();

            return(calclater.CreatePackageList(config, buildAssets, packageConfigList));
        }
Ejemplo n.º 14
0
        public virtual IList <IBundleFileManifest> Build(IBundleBuildConfig config, IReadOnlyList <string> packagedAssets)
        {
            var groups = m_group.GetGrouping(config, m_converter, packagedAssets);

            return(m_bundle.GetBundleList(config, groups, this));
        }
Ejemplo n.º 15
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);
        }
Ejemplo n.º 16
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));
        }
Ejemplo n.º 17
0
 protected virtual void DoProcess(RuntimePlatform platform, BuildTarget target, IBundleBuildConfig config, IList <IBundleFileManifest> bundleList)
 {
 }
Ejemplo n.º 18
0
 public IList <IBundleFileManifest> GetBundleList(IBundleBuildConfig config, IList <IBundleGroup> groups, BundlePackRule rule)
 {
     return(groups.Select(group => Build(config, group, rule)).ToArray());
 }
Ejemplo n.º 19
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);
     }
 }
Ejemplo n.º 20
0
 public abstract IList <IBundleFileManifest> CreatePackageList(
     IBundleBuildConfig config,
     IReadOnlyList <string> buildAssets,
     IList <IBundlePackRule> packageConfigList
     );