static void _CreateAssetBunldesMain(string targetPath) { #if !UNITY_5 Object[] SelectedAsset = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets); foreach (Object obj in SelectedAsset) { if (BuildPipeline.BuildAssetBundle(obj, null, (targetPath + obj.name + ".assetbundle").ToLower(), BuildAssetBundleOptions.CollectDependencies)) { UnityLog.Log(obj.name + "is build success."); } else { UnityLog.Log(obj.name + "is build failure."); } } AssetDatabase.Refresh(); #else System.Action <string> cb = (str) => { string name = str; if (!string.IsNullOrEmpty(name) && !name.EndsWith(FGame.Manager.ResourceManager.assetExt)) { name = name + FGame.Manager.ResourceManager.assetExt; } name = name != null ? name : FGame.Manager.ResourceManager.assetDir + FGame.Manager.ResourceManager.assetExt; Object[] SelectedAsset = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets); HashSet <string> assetList = new HashSet <string>(); //Dictionary<string, HashSet<string>> allBundles = new Dictionary<string, HashSet<string>>(); foreach (Object obj in SelectedAsset) { string assetPath = AssetDatabase.GetAssetPath(obj); //AssetImporter import = AssetImporter.GetAtPath(assetPath); //if (!string.IsNullOrEmpty(import.assetBundleName)) //{ // if (allBundles.ContainsKey(import.assetBundleName)) // allBundles[import.assetBundleName].Add(assetPath); // else // allBundles.Add(import.assetBundleName, new HashSet<string>() { assetPath }); //} assetList.Add(assetPath); } List <string> tempList = new List <string>(); tempList.AddRange(assetList); string[] buildList = tempList.ToArray();// AssetDatabase.GetDependencies(tempList.ToArray()); AssetBundleBuild build = new AssetBundleBuild(); build.assetBundleName = name; build.assetNames = buildList; BuildAssetBundleOptions options = BuildAssetBundleOptions.DeterministicAssetBundle | BuildAssetBundleOptions.UncompressedAssetBundle; BuildPipeline.BuildAssetBundles(targetPath, new AssetBundleBuild[] { build }, options, EditorUserBuildSettings.activeBuildTarget); AssetDatabase.Refresh(); UnityLog.Log(name + "is build success."); }; ExInputWindow.Open(cb); #endif }
public static void Open(System.Action <string> _cb, string _szLabelTitle = "Input", string _szInput = "") { cb = _cb; szLabelTitle = _szLabelTitle; szInput = _szInput; window = EditorWindow.GetWindowWithRect <ExInputWindow>(new Rect(Screen.width / 2, Screen.height / 2, 260, 50)); window.title = "InputWindow"; window.ShowPopup(); }
void OnDestroy() { window = null; }