@@ -177,7 +177,7 @@ protected override void ContextClickedItem(int id)
177177 {
178178 menu . AddItem ( new GUIContent ( "Move duplicates shared by selected" ) , false , DedupeOverlappedBundles , selectedNodes ) ;
179179 menu . AddItem ( new GUIContent ( "Move duplicates existing in any selected" ) , false , DedupeAllBundles , selectedNodes ) ;
180- menu . AddItem ( new GUIContent ( "Delete multiple bundles" ) , false , DeleteBundles , selectedNodes ) ;
180+ menu . AddItem ( new GUIContent ( "Delete " + selectedNodes . Count + " selected bundles") , false , DeleteBundles , selectedNodes ) ;
181181 }
182182 menu . ShowAsContext ( ) ;
183183 }
@@ -424,7 +424,7 @@ protected override DragAndDropVisualMode HandleDragAndDrop(DragAndDropArgs args)
424424 case DragAndDropPosition . OutsideItems :
425425 if ( data . draggedNodes != null )
426426 {
427- visualMode = DragAndDropVisualMode . Copy ; // Generic;
427+ visualMode = DragAndDropVisualMode . Copy ;
428428 if ( data . args . performDrop )
429429 {
430430 AssetBundleModel . Model . HandleBundleReparent ( data . draggedNodes , null ) ;
@@ -433,10 +433,10 @@ protected override DragAndDropVisualMode HandleDragAndDrop(DragAndDropArgs args)
433433 }
434434 else if ( data . paths != null )
435435 {
436- visualMode = DragAndDropVisualMode . Copy ; //Generic;
436+ visualMode = DragAndDropVisualMode . Copy ;
437437 if ( data . args . performDrop )
438438 {
439- DragPathsToNewSpace ( data . paths , null , data . hasScene ) ;
439+ DragPathsToNewSpace ( data . paths , null ) ;
440440 }
441441 }
442442 break ;
@@ -451,31 +451,39 @@ private DragAndDropVisualMode HandleDragDropUpon(DragAndDropData data)
451451 if ( targetDataBundle != null )
452452 {
453453 if ( targetDataBundle . isSceneBundle )
454- visualMode = DragAndDropVisualMode . Rejected ;
454+ {
455+ if ( data . hasNonScene )
456+ return DragAndDropVisualMode . Rejected ;
457+ }
455458 else
456459 {
457- if ( ( data . hasBundleFolder ) || ( data . hasScene && ! targetDataBundle . IsEmpty ( ) ) )
460+ if ( data . hasBundleFolder )
458461 {
459462 return DragAndDropVisualMode . Rejected ;
460463 }
461- else
464+ else if ( data . hasScene && ! targetDataBundle . IsEmpty ( ) )
462465 {
463- if ( data . args . performDrop )
464- {
465- if ( data . draggedNodes != null )
466- {
467- AssetBundleModel . Model . HandleBundleMerge ( data . draggedNodes , targetDataBundle ) ;
468- ReloadAndSelect ( targetDataBundle . nameHashCode , false ) ;
469- }
470- else if ( data . paths != null )
471- {
472- AssetBundleModel . Model . MoveAssetToBundle ( data . paths , targetDataBundle . m_Name . bundleName , targetDataBundle . m_Name . variant ) ;
473- AssetBundleModel . Model . ExecuteAssetMove ( ) ;
474- ReloadAndSelect ( targetDataBundle . nameHashCode , false ) ;
475- }
476- }
466+ return DragAndDropVisualMode . Rejected ;
477467 }
468+
478469 }
470+
471+
472+ if ( data . args . performDrop )
473+ {
474+ if ( data . draggedNodes != null )
475+ {
476+ AssetBundleModel . Model . HandleBundleMerge ( data . draggedNodes , targetDataBundle ) ;
477+ ReloadAndSelect ( targetDataBundle . nameHashCode , false ) ;
478+ }
479+ else if ( data . paths != null )
480+ {
481+ AssetBundleModel . Model . MoveAssetToBundle ( data . paths , targetDataBundle . m_Name . bundleName , targetDataBundle . m_Name . variant ) ;
482+ AssetBundleModel . Model . ExecuteAssetMove ( ) ;
483+ ReloadAndSelect ( targetDataBundle . nameHashCode , false ) ;
484+ }
485+ }
486+
479487 }
480488 else
481489 {
@@ -491,7 +499,7 @@ private DragAndDropVisualMode HandleDragDropUpon(DragAndDropData data)
491499 }
492500 else if ( data . paths != null )
493501 {
494- DragPathsToNewSpace ( data . paths , folder , data . hasScene ) ;
502+ DragPathsToNewSpace ( data . paths , folder ) ;
495503 }
496504 }
497505 }
@@ -525,7 +533,7 @@ private DragAndDropVisualMode HandleDragDropBetween(DragAndDropData data)
525533 }
526534 else if ( data . paths != null )
527535 {
528- DragPathsToNewSpace ( data . paths , folder , data . hasScene ) ;
536+ DragPathsToNewSpace ( data . paths , folder ) ;
529537 }
530538 }
531539 }
@@ -534,28 +542,46 @@ private DragAndDropVisualMode HandleDragDropBetween(DragAndDropData data)
534542 return visualMode ;
535543 }
536544
537- private void DragPathsToNewSpace ( string [ ] paths , AssetBundleModel . BundleFolderInfo root , bool hasScene )
545+ private string [ ] dragToNewSpacePaths = null ;
546+ private AssetBundleModel . BundleFolderInfo dragToNewSpaceRoot = null ;
547+ private void DragPathsAsOneBundle ( )
538548 {
539- if ( hasScene )
549+ var newBundle = AssetBundleModel . Model . CreateEmptyBundle ( dragToNewSpaceRoot ) ;
550+ AssetBundleModel . Model . MoveAssetToBundle ( dragToNewSpacePaths , newBundle . m_Name . bundleName , newBundle . m_Name . variant ) ;
551+ AssetBundleModel . Model . ExecuteAssetMove ( ) ;
552+ ReloadAndSelect ( newBundle . nameHashCode , true ) ;
553+ }
554+ private void DragPathsAsManyBundles ( )
555+ {
556+ List < int > hashCodes = new List < int > ( ) ;
557+ foreach ( var assetPath in dragToNewSpacePaths )
540558 {
541- List < int > hashCodes = new List < int > ( ) ;
542- foreach ( var assetPath in paths )
543- {
544- var newBundle = AssetBundleModel . Model . CreateEmptyBundle ( root , System . IO . Path . GetFileNameWithoutExtension ( assetPath ) . ToLower ( ) ) ;
545- AssetBundleModel . Model . MoveAssetToBundle ( assetPath , newBundle . m_Name . bundleName , newBundle . m_Name . variant ) ;
546- hashCodes . Add ( newBundle . nameHashCode ) ;
547- }
548- AssetBundleModel . Model . ExecuteAssetMove ( ) ;
549- ReloadAndSelect ( hashCodes ) ;
559+ var newBundle = AssetBundleModel . Model . CreateEmptyBundle ( dragToNewSpaceRoot , System . IO . Path . GetFileNameWithoutExtension ( assetPath ) . ToLower ( ) ) ;
560+ AssetBundleModel . Model . MoveAssetToBundle ( assetPath , newBundle . m_Name . bundleName , newBundle . m_Name . variant ) ;
561+ hashCodes . Add ( newBundle . nameHashCode ) ;
550562 }
551- else
563+ AssetBundleModel . Model . ExecuteAssetMove ( ) ;
564+ ReloadAndSelect ( hashCodes ) ;
565+ }
566+
567+ private void DragPathsToNewSpace ( string [ ] paths , AssetBundleModel . BundleFolderInfo root )
568+ {
569+ dragToNewSpacePaths = paths ;
570+ dragToNewSpaceRoot = root ;
571+ if ( paths . Length > 1 )
552572 {
553- var newBundle = AssetBundleModel . Model . CreateEmptyBundle ( root ) ;
554- AssetBundleModel . Model . MoveAssetToBundle ( paths , newBundle . m_Name . bundleName , newBundle . m_Name . variant ) ;
555- AssetBundleModel . Model . ExecuteAssetMove ( ) ;
556- ReloadAndSelect ( newBundle . nameHashCode , true ) ;
573+ GenericMenu menu = new GenericMenu ( ) ;
574+ menu . AddItem ( new GUIContent ( "Create 1 Bundle" ) , false , DragPathsAsOneBundle ) ;
575+ var message = "Create " ;
576+ message += paths . Length ;
577+ message += " Bundles" ;
578+ menu . AddItem ( new GUIContent ( message ) , false , DragPathsAsManyBundles ) ;
579+ menu . ShowAsContext ( ) ;
557580 }
581+ else
582+ DragPathsAsManyBundles ( ) ;
558583 }
584+
559585 protected override void SetupDragAndDrop ( SetupDragAndDropArgs args )
560586 {
561587 DragAndDrop . PrepareStartDrag ( ) ;
@@ -575,7 +601,6 @@ protected override void SetupDragAndDrop(SetupDragAndDropArgs args)
575601
576602 protected override bool CanStartDrag ( CanStartDragArgs args )
577603 {
578- //args.draggedItemIDs = GetSelection();
579604 return true ;
580605 }
581606
0 commit comments