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); }
void OnGUI() { if (m_bundleTree == null) { if (m_selectionTreeState == null) { m_selectionTreeState = new TreeViewState(); } m_selectionList = new SelectionListTree(m_selectionTreeState); m_selectionList.Reload(); if (m_assetListState == null) { m_assetListState = new TreeViewState(); m_assetListMCHState = new MultiColumnHeaderState(AssetListTree.GetColumns()); } m_assetList = new AssetListTree(m_assetListState, m_assetListMCHState, m_selectionList); m_assetList.Reload(); if (m_bundleTreeState == null) { m_bundleTreeState = new TreeViewState(); } m_bundleTree = new AssetBundleTree(m_bundleTreeState, m_assetList); m_bundleTree.Refresh(); Repaint(); } HandleHorizontalResize(); HandleVerticalResize(); if (GUI.Button(new Rect(0, kToolbarHeight, m_horizontalSplitterRect.x / 2, 25), new GUIContent("New Bundle"))) { AssetBundleState.GetBundle(null); } // if (GUI.Button(new Rect(m_horizontalSplitterRect.x / 2, kToolbarHeight, m_horizontalSplitterRect.x / 2, 25), new GUIContent("New Folder"))) // ;// m_bundleTree.Add // if (GUI.Button(new Rect(m_horizontalSplitterRect.x / 2, kToolbarHeight, m_horizontalSplitterRect.x/2, 25), new GUIContent("RESET"))) // AssetBundleState.Rebuild(); m_bundleTree.OnGUI(new Rect(0, kToolbarHeight + 25 + kSplitterWidth, m_horizontalSplitterRect.x, position.height - (kToolbarHeight * 2 + kSplitterWidth * 2 + 25))); float panelLeft = m_horizontalSplitterRect.x + kSplitterWidth; float panelWidth = (position.width - m_horizontalSplitterRect.x) - kSplitterWidth * 2; float panelHeight = m_verticalSplitterRect.y - kToolbarHeight; m_assetList.OnGUI(new Rect(panelLeft, kToolbarHeight, panelWidth, panelHeight)); m_selectionList.OnGUI(new Rect(panelLeft, m_verticalSplitterRect.y + kSplitterWidth, panelWidth, (position.height - m_verticalSplitterRect.y) - kSplitterWidth * 2)); if (m_resizingHorizontalSplitter || m_resizingVerticalSplitter) { Repaint(); } }