void DeleteBundles(object b)
        {
            var selectedNodes = b as List <AssetBundleState.BundleInfo.TreeItem>;
            List <AssetBundleState.BundleInfo> bundles = new List <AssetBundleState.BundleInfo>();

            foreach (var n in selectedNodes)
            {
                GatherAllBundlesFromNode(n, bundles);
            }
            var sb = new System.Text.StringBuilder();

            foreach (var r in bundles)
            {
                sb.AppendLine(r.m_name);
            }
            if (EditorUtility.DisplayDialog("Bundle delete confirmation", "Do you want to delete these bundles:" + Environment.NewLine + sb.ToString(), "Yes", "No"))
            {
                AssetBundleState.StartABMoveBatch();
                foreach (var r in bundles)
                {
                    AssetBundleState.RenameBundle(r, string.Empty);
                }
                AssetBundleState.EndABMoveBatch();
            }
        }
 protected override DragAndDropVisualMode HandleDragAndDrop(DragAndDropArgs args)
 {
     if (args.dragAndDropPosition == DragAndDropPosition.UponItem)
     {
         if (args.performDrop)
         {
             var targetBundle = (args.parentItem as AssetBundleState.BundleInfo.TreeItem).bundle;
             if (targetBundle != null)
             {
                 AssetBundleState.MoveAssetsToBundle(DragAndDrop.paths.Select(a => AssetBundleState.GetAsset(a)), targetBundle.m_name);
                 SelectionChanged(GetSelection());
             }
         }
         return(DragAndDropVisualMode.Move);
     }
     else
     {
         if (args.performDrop)
         {
             AssetBundleState.StartABMoveBatch();
             foreach (var a in DragAndDrop.paths)
             {
                 if (AssetDatabase.GetMainAssetTypeAtPath(a) == typeof(SceneAsset))
                 {
                     var bundle = AssetBundleState.GetBundle(System.IO.Path.GetFileNameWithoutExtension(a).ToLower());
                     AssetBundleState.MoveAssetsToBundle(new AssetBundleState.AssetInfo[] { AssetBundleState.GetAsset(a) }, bundle.m_name);
                 }
             }
             AssetBundleState.EndABMoveBatch();
             return(DragAndDropVisualMode.Move);
         }
     }
     return(DragAndDropVisualMode.Move);
 }
        protected override DragAndDropVisualMode HandleDragAndDrop(DragAndDropArgs args)
        {
            if (args.dragAndDropPosition == DragAndDropPosition.UponItem)
            {
                if (args.performDrop)
                {
                    var targetNode   = args.parentItem as AssetBundleState.BundleInfo.TreeItem;
                    var targetBundle = targetNode.bundle;
                    var draggedNodes = DragAndDrop.GetGenericData("AssetBundleState.BundleInfo.TreeItem") as List <AssetBundleState.BundleInfo.TreeItem>;
                    if (draggedNodes != null)
                    {
                        foreach (var draggedNode in draggedNodes)
                        {
                            var res = new List <AssetBundleState.BundleInfo>();
                            GatherAllBundlesFromNode(draggedNode, res);
                            AssetBundleState.StartABMoveBatch();
                            foreach (var b in res)
                            {
                                var dstBundle = targetNode.GetPath() + "/" + b.m_name.Substring(b.m_name.IndexOf(draggedNode.displayName));
                                AssetBundleState.MoveAssetsToBundle(b.m_assets.Values, dstBundle);
                            }
                            AssetBundleState.EndABMoveBatch();

                            foreach (var b in res)
                            {
                                AssetBundleState.RemoveBundle(b.m_name);
                            }
                            AssetBundleState.RemoveBundle(draggedNode.GetPath());
                        }
                        Reload();
                    }
                    else if (DragAndDrop.paths != null)
                    {
                        AssetBundleState.StartABMoveBatch();
                        AssetBundleState.MoveAssetsToBundle(DragAndDrop.paths.Select(a => AssetBundleState.GetAsset(a)), targetNode.GetPath());
                        AssetBundleState.EndABMoveBatch();
                    }
                }
                return(DragAndDropVisualMode.Move);
            }
            else
            {
                if (args.performDrop)
                {
                    AssetBundleState.StartABMoveBatch();
                    foreach (var a in DragAndDrop.paths)
                    {
                        if (AssetDatabase.GetMainAssetTypeAtPath(a) == typeof(SceneAsset))
                        {
                            var bundle = AssetBundleState.GetBundle(System.IO.Path.GetFileNameWithoutExtension(a).ToLower());
                            AssetBundleState.MoveAssetsToBundle(new AssetBundleState.AssetInfo[] { AssetBundleState.GetAsset(a) }, bundle.m_name);
                        }
                    }
                    AssetBundleState.EndABMoveBatch();
                    return(DragAndDropVisualMode.Move);
                }
            }
            return(DragAndDropVisualMode.Move);
        }
 protected override void KeyEvent()
 {
     if (m_data != null && Event.current.keyCode == KeyCode.Delete && GetSelection().Count > 0)
     {
         AssetBundleState.StartABMoveBatch();
         AssetBundleState.MoveAssetsToBundle(GetSelectedAssets(), string.Empty);
         AssetBundleState.EndABMoveBatch();
         SetSelectedBundles(m_data.m_bundles);
         Event.current.Use();
     }
 }
        protected override DragAndDropVisualMode HandleDragAndDrop(DragAndDropArgs args)
        {
            if (m_data == null)
            {
                return(DragAndDropVisualMode.Rejected);
            }

            if (args.performDrop)
            {
                AssetBundleState.StartABMoveBatch();
                foreach (var b in m_data.m_bundles)
                {
                    AssetBundleState.MoveAssetsToBundle(DragAndDrop.paths.Select(a => AssetBundleState.GetAsset(a)), b.m_name);
                }
                AssetBundleState.EndABMoveBatch();
                SetSelectedBundles(m_data.m_bundles);
            }

            return(DragAndDropVisualMode.Move);
        }
 protected override void RenameEnded(RenameEndedArgs args)
 {
     if (args.newName.Length > 0 && args.newName != args.originalName && !AssetBundleState.m_bundles.ContainsKey(args.newName))
     {
         args.acceptedRename = true;
         var node = Utilities.FindItem <AssetBundleState.BundleInfo.TreeItem>(rootItem, args.itemID);
         List <AssetBundleState.BundleInfo> bundles = new List <AssetBundleState.BundleInfo>();
         GatherAllBundlesFromNode(node, bundles);
         AssetBundleState.StartABMoveBatch();
         foreach (var b in bundles)
         {
             AssetBundleState.RenameBundle(b, b.m_name.Replace(args.originalName, args.newName));
         }
         AssetBundleState.EndABMoveBatch();
     }
     else
     {
         args.acceptedRename = false;
     }
     Reload();
 }
        void DedupeBundles(object context)
        {
            var selectedNodes = context as List <AssetBundleState.BundleInfo.TreeItem>;
            List <AssetBundleState.BundleInfo> bundles = new List <AssetBundleState.BundleInfo>();

            foreach (var n in selectedNodes)
            {
                GatherAllBundlesFromNode(n, bundles);
            }
            var allAssets        = new HashSet <string>();
            var duplicatedAssets = new List <AssetBundleState.AssetInfo>();

            foreach (var b in bundles)
            {
                var deps = new List <AssetBundleState.AssetInfo>();
                b.GatherImplicitDependencies(deps);
                foreach (var d in deps)
                {
                    if (allAssets.Contains(d.m_name))
                    {
                        duplicatedAssets.Add(d);
                    }
                    else
                    {
                        allAssets.Add(d.m_name);
                    }
                }
            }

            if (duplicatedAssets.Count > 0)
            {
                AssetBundleState.StartABMoveBatch();
                AssetBundleState.MoveAssetsToBundle(duplicatedAssets, null);
                AssetBundleState.EndABMoveBatch();
            }
        }