| | |
| | | }
|
| | | } |
| | | |
| | | [MenuItem("Assets/BuildAssetBundle ( Test )")] |
| | | public static void BuildTest()
|
| | | {
|
| | | if (Selection.activeObject != null) |
| | | { |
| | | var path = AssetDatabase.GetAssetPath(Selection.activeObject);
|
| | | var importer = AssetImporter.GetAtPath(path); |
| | | |
| | | if (importer != null) |
| | | { |
| | | var ab = importer.assetBundleName; |
| | | if (!string.IsNullOrEmpty(ab)) |
| | | {
|
| | |
|
| | | var assetBundles = AssetDatabase.GetAllAssetBundleNames();
|
| | |
|
| | | List<string> targetAssetBundles = new List<string>();
|
| | | for (int i = 0; i < assetBundles.Length; i++)
|
| | | {
|
| | | var bundleName = assetBundles[i];
|
| | | if (bundleName == ab)
|
| | | {
|
| | | targetAssetBundles.Add(bundleName);
|
| | | }
|
| | | }
|
| | |
|
| | | var assets = new List<AssetBundleBuild>();
|
| | | for (int i = 0; i < targetAssetBundles.Count; i++)
|
| | | {
|
| | | var assetBundleBuild = new AssetBundleBuild();
|
| | | assetBundleBuild.assetBundleName = targetAssetBundles[i];
|
| | | assetBundleBuild.assetNames = AssetDatabase.GetAssetPathsFromAssetBundle(targetAssetBundles[i]);
|
| | | assets.Add(assetBundleBuild);
|
| | | }
|
| | |
|
| | | var opt = BuildAssetBundleOptions.None
|
| | | | BuildAssetBundleOptions.ChunkBasedCompression
|
| | | | BuildAssetBundleOptions.DeterministicAssetBundle;
|
| | |
|
| | | var dirctory = Application.dataPath + "/BundleTest";
|
| | | if (!Directory.Exists(dirctory)) |
| | | { |
| | | Directory.CreateDirectory(dirctory); |
| | | }
|
| | | BuildPipeline.BuildAssetBundles(dirctory, assets.ToArray(), opt, BuildTarget.Android); |
| | | } |
| | | } |
| | | |
| | | }
|
| | | } |
| | | |
| | | } |