private DragAndDropVisualMode DragAndDropFromOutside(DragAndDropArgs args) { if (args.parentItem?.depth == 1) { return(DragAndDropVisualMode.None); } if (!args.performDrop) { return(DragAndDropVisualMode.Copy); } if (args.parentItem?.depth == 0) { foreach (string path in DragAndDrop.paths) { var importer = AssetImporter.GetAtPath(path); importer.assetBundleName = args.parentItem.displayName; } Reload(); return(DragAndDropVisualMode.Copy); } if (DragAndDrop.paths.Length > 1) { var menu = new GenericMenu(); menu.AddItem(new GUIContent("Create Separate Bundles"), false, () => { foreach (string path in DragAndDrop.paths) { _bundlesSp.AddBundle(path); } Reload(); }); menu.AddItem(new GUIContent("Create One Bundle"), false, async() => { _parentWindow.Focus(); string abName = "new_assetbundle_name"; _bundlesSp.AddBundle(abName, BundleType.Static, DragAndDrop.paths); Reload(); var newItem = GetRows().Last(); SetSelection(new[] { newItem.id }); EndRename(); BeginRename(newItem); }); menu.ShowAsContext(); return(DragAndDropVisualMode.Copy); } _bundlesSp.AddBundle(DragAndDrop.paths.First()); Reload(); return(DragAndDropVisualMode.Copy); }
public static void AddOrUpdateBundle(this SerializedProperty bundles, string name, BundleType bundleType, params string[] assetPaths) { var b = bundles.FindBundle(name); if (b == null) { bundles.AddBundle(name, bundleType, assetPaths); return; } b.SetBundleType(bundleType); b.Dispose(); }
public static string AddBundle(this SerializedProperty bundles, Object asset, BundleType bundleType = BundleType.Static) { return(bundles.AddBundle(AssetDatabase.GetAssetPath(asset), bundleType)); }