예제 #1
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);
                }
            }
        }
예제 #2
0
        //ファイルのコンバート
        void Convert()
        {
            try
            {
                AssetFileManager assetFileManager = FindObjectOfType <AssetFileManager>();
                if (assetFileManager == null)
                {
                    Debug.LogError("FileManager is not found in current scene");
                    return;
                }
                //ファイルの入出力に使う
                FileIOManager            fileIOManager = assetFileManager.FileIOManger;
                AssetFileManagerSettings settings      = assetFileManager.Settings;

                if (outputType == OutputType.Default)
                {
                    AssetFileManagerSettings.LoadType loadType = settings.LoadTypeSetting;
                    if (isOutputLocal && LocalDirectory != null)
                    {
                        //ローカルの場合は、LoadTypeをLocalCompressedに
                        settings.LoadTypeSetting = AssetFileManagerSettings.LoadType.LocalCompressed;
                        string output = new MainAssetInfo(LocalDirectory).FullPath;
                        //リソースをバージョンアップ
                        AdvFileListConverter converter = new AdvFileListConverter(output, fileIOManager, settings);
                        converter.VersionUp(VersionUpLocalFiles);
                        if (isOutputLocalLog)
                        {
                            converter.WriteLog(false);
                        }
                    }
                    if (isOutputServer && !string.IsNullOrEmpty(OutputServerResourcePath))
                    {
                        //サーバーの場合は、LoadTypeをServerに
                        settings.LoadTypeSetting = AssetFileManagerSettings.LoadType.Server;
                        //シナリオやリソースをバージョンアップ
                        AdvFileListConverter converter = new AdvFileListConverter(OutputServerResourcePath, fileIOManager, settings);
                        converter.VersionUp(VersionUpServerFiles);
                        if (isOutputServerLog)
                        {
                            converter.WriteLog(false);
                        }
                        //アセットバンドルをビルド
                        BuildAssetBundles(OutputServerResourcePath, fileIOManager, settings, isOutputServerLog);
                    }
                    settings.LoadTypeSetting = loadType;
                }
                else
                {
                    //シナリオやリソースをバージョンアップ
                    AdvFileListConverter converter = new AdvFileListConverter(AdvancedOutputPath, fileIOManager, settings);
                    converter.VersionUp(VersionUpAdvanceFiles);
                    if (isOutputAdvancedLog)
                    {
                        converter.WriteLog(false);
                    }
                    //アセットバンドルをビルド
                    BuildAssetBundles(AdvancedOutputPath, fileIOManager, settings, isOutputAdvancedLog);
                }

                AssetDatabase.Refresh();
            }
            catch (System.Exception e)
            {
                Debug.LogException(e);
            }
        }