public static List <AssetBundleBuild> PackAssetBundles() { if (EditorApplication.isCompiling) { EditorUtility.DisplayDialog("", "Script is compiling, try again later.", "Yes"); return(null); } //Complie Lua File //LuaPackager.EncodeLuaFiles(); //Read The Build Config File Dictionary <string, int> config = new Dictionary <string, int>(); EditorUtil.ReadAssetConfig(config); //Get All AssetBundle File List <AssetBundleBuild> buildmap = new List <AssetBundleBuild>(); foreach (var pair in config) { BundleAction handler = allHandler[pair.Value - 1]; string path = EditorConst.ASSET_ROOT + pair.Key; if (Directory.Exists(path)) { var builds = handler.Invoke(path); buildmap.AddRange(builds as IEnumerable <AssetBundleBuild>); } } if (!Directory.Exists(OUTPUT_ROOT)) { Directory.CreateDirectory(OUTPUT_ROOT); } DoMakeAssetBundleAssetConfig(EditorConst.ASSET_CONFIG_PATH, buildmap); DoMakeAssetBundleLuaConfig(EditorConst.LUA_CONFIG_PATH, buildmap); AssetDatabase.Refresh(); //Begin Build PipeLine BuildPipeline.BuildAssetBundles(OUTPUT_ROOT, buildmap.ToArray(), BuildAssetBundleOptions.ChunkBasedCompression, EditorUserBuildSettings.activeBuildTarget); // Handle The Main Manifest string manifestPath = OUTPUT_ROOT + Path.GetFileName(Path.GetDirectoryName(OUTPUT_ROOT)); File.Copy(manifestPath, OUTPUT_ROOT + AB_MANIFEST + AB_EXTENSION, true); File.Delete(manifestPath); File.Copy(manifestPath + ".manifest", OUTPUT_ROOT + AB_MANIFEST + ".manifest", true); File.Delete(manifestPath + ".manifest"); AssetBundleBuild abb = new AssetBundleBuild(); abb.assetBundleName = AB_MANIFEST + AB_EXTENSION; buildmap.Add(abb); BuildVersionFile(VERSION_PATH, OUTPUT_ROOT, buildmap); AssetDatabase.Refresh(); UnityEngine.Debug.Log("Build assetbundles files finish!!"); return(buildmap); }
private static void BuildLua() { //Encode LuaPackager.EncodeLuaFiles(); //Build AB //Get Lua AssetBundle File //Read The Build Config File Dictionary <string, int> config = new Dictionary <string, int>(); EditorUtil.ReadAssetConfig(config); List <AssetBundleBuild> buildmap = new List <AssetBundleBuild>(); foreach (var pair in config) { BundleAction handler = allHandler[pair.Value - 1]; string path = EditorConst.ASSET_ROOT + pair.Key; if (Directory.Exists(path) && pair.Key.StartsWith("Lua")) { var builds = handler.Invoke(path); buildmap.AddRange(builds as IEnumerable <AssetBundleBuild>); } } DoMakeAssetBundleLuaConfig(EditorConst.LUA_CONFIG_PATH, buildmap); DoMakeAssetBundleAssetConfig(EditorConst.ASSET_CONFIG_PATH, buildmap); BuildPipeline.BuildAssetBundles(OUTPUT_ROOT, buildmap.ToArray(), BuildAssetBundleOptions.ChunkBasedCompression, EditorUserBuildSettings.activeBuildTarget); UnityEngine.Debug.Log("Build Lua Finish!!"); }