From 723604e6defc7414b0423c3d0d6980233531659b Mon Sep 17 00:00:00 2001 From: client_Wu Xijin <364452445@qq.com> Date: 星期五, 09 十一月 2018 09:42:44 +0800 Subject: [PATCH] Merge branch 'master' into leonard --- Assets/Editor/Tool/AssetBundleBuildExtersion.cs | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 51 insertions(+), 0 deletions(-) diff --git a/Assets/Editor/Tool/AssetBundleBuildExtersion.cs b/Assets/Editor/Tool/AssetBundleBuildExtersion.cs index be8984d..6008b6c 100644 --- a/Assets/Editor/Tool/AssetBundleBuildExtersion.cs +++ b/Assets/Editor/Tool/AssetBundleBuildExtersion.cs @@ -75,4 +75,55 @@ } } + [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); + } + } + + } + } + } -- Gitblit v1.8.0