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.MoveAssetsToBundle(GetSelectedAssets(), string.Empty); SetSelectedBundle(m_data.m_bundle); Event.current.Use(); } }
protected override DragAndDropVisualMode HandleDragAndDrop(DragAndDropArgs args) { if (m_data == null) { return(DragAndDropVisualMode.Rejected); } if (args.performDrop) { AssetBundleState.MoveAssetsToBundle(DragAndDrop.paths.Select(a => AssetBundleState.GetAsset(a)), m_data.m_bundle.m_name); SetSelectedBundle(m_data.m_bundle); } return(DragAndDropVisualMode.Move); }
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); }
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(); } }