3using System.Collections;
16 [MenuItem(
"Tools/Level Editor/Build Asset Bundles")]
17 static void BuildAssetBundle()
19 if(!
Directory.Exists(
"Assets/AssetBundles"))
20 Directory.CreateDirectory(
"Assets/AssetBundles");
23 foreach(
string bundle_name
in AssetDatabase.GetAllAssetBundleNames())
25 if(pb_Config.AssetBundle_Names.Any(x => x.IndexOf(bundle_name, StringComparison.OrdinalIgnoreCase) >= 0))
27 foreach(
string asset_path
in AssetDatabase.GetAssetPathsFromAssetBundle(bundle_name))
29 SetMetadata(asset_path, bundle_name);
34 BuildPipeline.BuildAssetBundles(
"Assets/AssetBundles",
35 BuildAssetBundleOptions.UncompressedAssetBundle | BuildAssetBundleOptions.ForceRebuildAssetBundle,
36 EditorUserBuildSettings.activeBuildTarget );
39 private static void SetMetadata(
string path,
string name)
41 switch( pb_FileUtility.GetPathType(path) )
45 UnityEngine.Object obj = AssetDatabase.LoadMainAssetAtPath(path);
47 GameObject go = obj as GameObject;
49 if(go !=
null && PrefabUtility.GetPrefabType(go) == PrefabType.Prefab)
64 foreach(
string subdir
in Directory.GetDirectories(path))
65 SetMetadata(subdir, name);
67 foreach(
string asset
in Directory.GetFiles(path))
68 SetMetadata(asset, name);