はじめに
「Unity-MultiProcess-BuildPipeline」を Unity プロジェクトに導入することで
マルチプロセスでアセットバンドルをビルドできるようになり
ビルド時間を削減できるようになります
使い方
using System.Collections.Generic; using UnityEditor; public static class Example { [MenuItem( "Example/Build" )] private static void Build() { var buildSet = new SortedDictionary<string, string[]> { {"Assets/Res/64k.txt", new string[]{ "Assets/Res/64k.txt" } }, {"Assets/Res/128k.txt", new string[]{ "Assets/Res/128k.txt" } }, {"Assets/Res/196k.txt", new string[]{ "Assets/Res/196k.txt" } }, {"Assets/Res/CubeA.mat", new string[]{ "Assets/Res/CubeA.mat" } }, {"Assets/Res/CubeA.prefab", new string[]{ "Assets/Res/CubeA.prefab" } }, {"Assets/Res/CubeB.prefab", new string[]{ "Assets/Res/CubeB.prefab" } }, {"Assets/Res/CubeB1.mat", new string[]{ "Assets/Res/CubeB1.mat" } }, {"Assets/Res/CubeB2.mat", new string[]{ "Assets/Res/CubeB2.mat" } }, {"Assets/Res/CubeC.prefab", new string[]{ "Assets/Res/CubeC.prefab" } }, {"Assets/Res/CubeD.prefab", new string[] { "Assets/Res/CubeD.prefab", "Assets/Res/CubeD1.mat", "Assets/Res/CubeD2.mat", "Assets/Res/CubeD3.mat", "Assets/Res/CubeD4.mat", "Assets/Res/CubeD5.mat", "Assets/Res/CubeD6.mat", "Assets/Res/CubeD7.mat", "Assets/Res/CubeD8.mat", "Assets/Res/CubeD9.mat", "Assets/Res/CubeD10.mat", } }, }; var builds = new List<AssetBundleBuild>(); foreach ( var pair in buildSet ) { var build = new AssetBundleBuild { assetBundleName = pair.Key, assetNames = pair.Value, }; builds.Add( build ); } MultiProcessBuild.BuildPipeline.BuildAssetBundles ( output : "ab", builds : builds.ToArray(), options : BuildAssetBundleOptions.None, target : BuildTarget.Android ); } }
このようにビルド対象のアセットと依存関係を自前で定義して
MultiProcessBuild.BuildPipeline.BuildAssetBundles 関数を呼び出すことで
マルチプロセスでアセットバンドルをビルドできます
リポジトリの作者さんの環境ではビルド時間が 300分から 42分まで削減できたそうです