//アセットバンドルのビルド
        void BuildAssetBundles(FileIOManager fileIOManager)
        {
            if (buildMode == AssetBundleBuildMode.None)
            {
                return;
            }

            //アセットバンドルをプラットフォーム別にビルド
            List <BuildTarget> buildTargets = new List <BuildTarget>();

            switch (buildMode)
            {
            case AssetBundleBuildMode.OnlyEditor:                    //エディタ上のみ
                buildTargets.Add(AssetBundleHelper.BuildTargetFlagToBuildTarget(AssetBundleHelper.EditorAssetBundleTarget()));
                break;

            case AssetBundleBuildMode.AllPlatform:                    //全プラットフォーム
            {
                buildTargets = AssetBundleHelper.BuildTargetFlagsToBuildTargetList(buildTargetFlags);
            }
            break;

            default:
                break;
            }

            MainAssetInfo        inputDirAsset = new MainAssetInfo(this.ResourcesDirectory);
            List <MainAssetInfo> assets        = GetAssetBudleList(inputDirAsset);

            RenameAssetBundles(inputDirAsset.AssetPath, assets);
            AssetBundleBuild[] builds = ToAssetBundleBuilds(assets);
            if (builds.Length <= 0)
            {
                return;
            }


            foreach (BuildTarget buildTarget in buildTargets)
            {
                string outputPath = FilePathUtil.Combine(OutputPath, AssetBundleHelper.BuildTargetToBuildTargetFlag(buildTarget).ToString());
                //出力先のディレクトリを作成
                if (!Directory.Exists(outputPath))
                {
                    Directory.CreateDirectory(outputPath);
                }
                //アセットバンドルを作成
                AssetBundleManifest manifest = BuildPipeline.BuildAssetBundles(outputPath, builds, buildOptions, buildTarget);
                Debug.Log("BuildAssetBundles to " + buildTarget.ToString());
                if (isOutputLog)
                {
                    WriteManifestLog(manifest, outputPath);
                }
            }
        }
Пример #2
0
        //アセットバンドルのビルド
        void BuildAssetBundles(string outPutDirectoryPath, FileIOManager fileIOManager, AssetFileManagerSettings settings, bool isOutputLog)
        {
            if (assetBundleBuildMode == AssetBundleBuildMode.None)
            {
                return;
            }

            //アセットバンドルをプラットフォーム別にビルド
            List <BuildTarget> buildTargets = new List <BuildTarget>();

            switch (assetBundleBuildMode)
            {
            case AssetBundleBuildMode.OnlyEditor:                    //エディタ上のみ
                buildTargets.Add(EditorUserBuildSettings.activeBuildTarget);
                break;

            case AssetBundleBuildMode.AllPlatform:                    //全プラットフォーム
            {
                buildTargets = AssetBundleHelper.BuildTargetFlagsToBuildTargetList(buildTargetFlags);
            }
            break;

            default:
                break;
            }

            List <MainAssetInfo> assets = GetAssetBudleList(settings);

            RenameAssetBundles(assets);
            AssetBundleBuild[] builds = ToAssetBundleBuilds(assets);
            if (builds.Length <= 0)
            {
                return;
            }


            foreach (BuildTarget buildTarget in buildTargets)
            {
                string outputPath = FilePathUtil.Combine(outPutDirectoryPath, AssetBundleHelper.BuildTargetToBuildTargetFlag(buildTarget).ToString());
                //出力先のディレクトリを作成
                if (!Directory.Exists(outputPath))
                {
                    Directory.CreateDirectory(outputPath);
                }
                //アセットバンドルを作成
                AssetBundleManifest manifest = BuildPipeline.BuildAssetBundles(outputPath, builds, BuildAssetBundleOptions.None, buildTarget);

                //アセットバンドルの情報をバージョンアップ
                AdvFileListConverter converter = new AdvFileListConverter(outputPath, fileIOManager, settings);
                converter.VersionUp(
                    (x) =>
                {
                    int count = x.ConvertFileList.EditorVersionUpAssetBundle(manifest, buildTarget);
                    Debug.Log("" + count + " AsseBundle version up to target " + buildTarget.ToString());
                });
                if (isOutputLog)
                {
                    converter.WriteLog(true);
                }
            }
        }