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);
 }
예제 #2
0
        protected override DragAndDropVisualMode HandleElementsDragAndDrop(DragAndDropArgs args, LayerTreeElement[] elements)
        {
            if (args.performDrop)
            {
                if (args.dragAndDropPosition == DragAndDropPosition.UponItem)
                {
                    if (args.parentItem is TreeViewItem <LayerTreeElement> layerTreeItem)
                    {
                        ItemsDropped?.Invoke(elements, layerTreeItem.Data);
                    }
                }
                Reload();
                return(DragAndDropVisualMode.None);
            }

            switch (args.dragAndDropPosition)
            {
            default: {
                return(DragAndDropVisualMode.None);
            }

            case DragAndDropPosition.BetweenItems:
            case DragAndDropPosition.OutsideItems: {
                return(DragAndDropVisualMode.Rejected);
            }

            case DragAndDropPosition.UponItem: {
                if (args.parentItem is TreeViewItem <LayerTreeElement> layerTreeItem)
                {
                    return(layerTreeItem.Data.Type == LayerTreeViewElementType.Layer ? DragAndDropVisualMode.Link : DragAndDropVisualMode.Rejected);
                }
                return(DragAndDropVisualMode.Move);
            }
            }
        }
        protected override DragAndDropVisualMode HandleDragAndDrop(DragAndDropArgs args)
        {
            var idList   = DragAndDrop.paths.Select <string, int>(e => Int32.Parse(e));
            var elements = Root.GetChildren <T>(element => idList.Contains(element.Id));

            return(HandleElementsDragAndDrop(args, elements.ToArray()));
        }
예제 #4
0
    /// <summary>
    /// 这个文件是否能拖过来
    /// </summary>
    /// <param name="args"></param>
    /// <returns></returns>
    protected bool IsValidDragDrop(DragAndDropArgs args)
    {
        if (group == null)
        {
            return(false);
        }

        if (DragAndDrop.paths == null || DragAndDrop.paths.Length == 0)
        {
            return(false);
        }

        //从场景拖过来的不行//
        foreach (var assetPath in DragAndDrop.paths)
        {
            if (!assetPath.StartsWith(FileUtil.GetProjectRelativePath(assetPath)) && !assetPath.StartsWith("Assets/Resources"))
            {
                return(false);
            }

            Type t = AssetDatabase.GetMainAssetTypeAtPath(assetPath);

            if (!CanDropType.Contains(t) && !AssetDatabase.IsValidFolder(assetPath))
            {
                Debug.LogError("Type=" + t);
                return(false);
            }
        }
        return(true);
    }
        protected override DragAndDropVisualMode HandleDragAndDrop(DragAndDropArgs args)
        {
            // Check if we can handle the current drag data (could be dragged in from other areas/windows in the editor)
            var draggedRows = DragAndDrop.GetGenericData(k_GenericDragID) as List <TreeViewItem>;

            if (draggedRows == null)
            {
                return(DragAndDropVisualMode.None);
            }

            // Parent item is null when dragging outside any tree view items.
            switch (args.dragAndDropPosition)
            {
            case DragAndDropPosition.UponItem:
            case DragAndDropPosition.OutsideItems:
            case DragAndDropPosition.BetweenItems:
            {
                var  newParent = args.parentItem as TreeViewItemBase <BoneCache>;
                bool validDrag = false;
                validDrag = GetController().CanReparent(newParent, draggedRows);
                if (args.performDrop && validDrag)
                {
                    GetController().ReparentItems(newParent, draggedRows, args.insertAtIndex);
                    Reload();
                    var selectedIDs = draggedRows.ConvertAll(b => b.id);
                    SetSelection(selectedIDs, TreeViewSelectionOptions.RevealAndFrame);
                    SelectionChanged(selectedIDs);
                }
                return(validDrag ? DragAndDropVisualMode.Move : DragAndDropVisualMode.None);
            }
            }

            return(DragAndDropVisualMode.None);
        }
예제 #6
0
        protected override DragAndDropVisualMode HandleDragAndDrop(DragAndDropArgs args)
        {
            var render = AssetTreeManager.mIns.GetGuiRender(EditorContexts.mIns.Mode);

            if (render != null)
            {
                AssetDragAndDropArgs copyArgs = new AssetDragAndDropArgs();
                copyArgs.dragAndDropPosition = (AssetDragAndDropArgs.DragAndDropPosition)((int)args.dragAndDropPosition);
                copyArgs.insertAtIndex       = args.insertAtIndex;
                copyArgs.parentItem          = args.parentItem;
                copyArgs.performDrop         = args.performDrop;
                DragAndDropVisualMode result = DragAndDropVisualMode.Move;
                foreach (var subrender in render)
                {
                    if (subrender.TypeMode == _viewMode)
                    {
                        IGuiTree treeRender = subrender as IGuiTree;
                        if (treeRender != null)
                        {
                            treeRender.Drag(ref copyArgs, ref result);
                        }
                    }
                }
                return(result);
            }

            return(base.HandleDragAndDrop(args));
        }
예제 #7
0
        protected override DragAndDropVisualMode HandleDragAndDrop(DragAndDropArgs args)
        {
            if (args.dragAndDropPosition != DragAndDropPosition.BetweenItems)
            {
                return(DragAndDropVisualMode.None);
            }

            var id   = Int32.Parse(DragAndDrop.paths.First());
            var item = FindItem(id, rootItem);
            var row  = (ActionTreeViewItem)item;

            if (!row.isDraggable || args.parentItem != row.parent)
            {
                return(DragAndDropVisualMode.None);
            }

            if (args.performDrop)
            {
                if (item is BindingTreeItem)
                {
                    MoveBinding(args, row);
                }
                else if (item is ActionTreeItem)
                {
                    MoveAction(args, row);
                }

                m_ApplyAction();
                DragAndDrop.AcceptDrag();
            }
            return(DragAndDropVisualMode.Move);
        }
예제 #8
0
        protected override DragAndDropVisualMode HandleDragAndDrop(DragAndDropArgs args)
        {
            if (args.dragAndDropPosition == DragAndDropPosition.OutsideItems)
            {
                return(DragAndDropVisualMode.Rejected);
            }

            if (!args.performDrop)
            {
                return(DragAndDropVisualMode.Move);
            }
            AITreeItem droppedItem = (AITreeItem)FindItem((int)DragAndDrop.GetGenericData("AITree_Data"), rootItem);

            if (args.parentItem == rootItem && !droppedItem.IsBehaviorSet)
            {
                return(DragAndDropVisualMode.Rejected);
            }

            AITreeItem droppedOn = (AITreeItem)args.parentItem;

            if (!droppedItem.CanDropOn(droppedOn))
            {
                return(DragAndDropVisualMode.Rejected);
            }
            else if (droppedItem.IsBehaviorSet)
            {
                OnBehaviorSetDrop(droppedItem.GetBehaviorSet(), args.insertAtIndex);
            }

            return(DragAndDropVisualMode.Move);
        }
예제 #9
0
        //=======================================================
        // drag and drop
        //=======================================================

        protected override DragAndDropVisualMode HandleDragAndDrop(DragAndDropArgs args)
        {
            // remove item which came from category.
            var draggedCategory = DragAndDrop.GetGenericData("UnityEditorMemoCategoryDragging");

            if (draggedCategory != null)
            {
                return(DragAndDropVisualMode.None);
            }

            switch (args.dragAndDropPosition)
            {
            case DragAndDropPosition.UponItem: {
                if (args.performDrop)
                {
                    UndoHelper.EditorMemoUndo(UndoHelper.UNDO_MEMO_EDIT);
                    var target = (TreeViewItem <UnityEditorMemo>)args.parentItem;
                    target.data.ObjectRef = new UnityEditorMemoObject(DragAndDrop.objectReferences[0]);
                    RefreshCustomRowHeights();
                }
                return(DragAndDropVisualMode.Move);
            }
            }
            return(DragAndDropVisualMode.None);
        }
예제 #10
0
        protected override DragAndDropVisualMode HandleDragAndDrop(DragAndDropArgs args)
        {
            List <TreeViewItem> draggedItems = DragAndDrop.GetGenericData(DragKey) as List <TreeViewItem>;

            if (draggedItems == null)
            {
                return(DragAndDropVisualMode.None);
            }

            int[] draggedIds = draggedItems.Select(GetItemId).ToArray();

            switch (args.dragAndDropPosition)
            {
            case DragAndDropPosition.BetweenItems:
            {
                if (args.performDrop)
                {
                    ElementsDraggingCallback?.Invoke(args.insertAtIndex, draggedIds);
                }

                return(DragAndDropVisualMode.Move);
            }

            default:
                return(DragAndDropVisualMode.None);
            }
        }
예제 #11
0
        protected override DragAndDropVisualMode HandleDragAndDrop(DragAndDropArgs args)
        {
            if (args.dragAndDropPosition != DragAndDropPosition.BetweenItems)
            {
                return(DragAndDropVisualMode.Rejected);
            }
            if (args.performDrop)
            {
                switch (args.dragAndDropPosition)
                {
                case DragAndDropPosition.BetweenItems:
                    int insertIndex = args.insertAtIndex;
                    int hash        = (int)DragAndDrop.GetGenericData("GUID");
                    int oldIndex    = entityList.FindIndex((e) => e.GetValue <Entity>().GetInstanceID() == hash);
                    entityList.MoveElement(oldIndex, insertIndex);
                    break;

                case DragAndDropPosition.UponItem:
                case DragAndDropPosition.OutsideItems:
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                Reload();
            }
            return(DragAndDropVisualMode.Move);
        }
예제 #12
0
        protected override DragAndDropVisualMode HandleDragAndDrop(DragAndDropArgs args)
        {
            // Check if we can handle the current drag data (could be dragged in from other areas/windows in the editor)
            var draggedRows = DragAndDrop.GetGenericData(k_GenericDragID) as List <TreeViewItem>;

            if (draggedRows == null)
            {
                return(DragAndDropVisualMode.None);
            }

            // Parent item is null when dragging outside any tree view items.
            switch (args.dragAndDropPosition)
            {
            case DragAndDropPosition.UponItem:
            case DragAndDropPosition.BetweenItems:
            {
                var  newParent = args.parentItem as TreeViewItemBase <BoneCache>;
                bool validDrag = false;
                validDrag = GetController().CanReparent(newParent, draggedRows);
                if (args.performDrop && validDrag)
                {
                    GetController().ReparentItems(newParent, draggedRows);
                    Reload();
                }
                return(validDrag ? DragAndDropVisualMode.Move : DragAndDropVisualMode.None);
            }

            case DragAndDropPosition.OutsideItems:
                return(DragAndDropVisualMode.None);    //TODO: Reparent to skeleton root
            }

            return(DragAndDropVisualMode.None);
        }
예제 #13
0
        protected override DragAndDropVisualMode HandleDragAndDrop(DragAndDropArgs args)
        {
            if (args.dragAndDropPosition != DragAndDropPosition.BetweenItems)
            {
                return(DragAndDropVisualMode.None);
            }

            var id   = Int32.Parse(DragAndDrop.paths.First());
            var item = FindItem(id, rootItem);
            var row  = (ActionMapTreeItem)item;

            if (!row.isDraggable || args.parentItem != row.parent)
            {
                return(DragAndDropVisualMode.None);
            }

            if (args.performDrop)
            {
                var dstIndex = args.insertAtIndex;
                var srcIndex = row.index;

                if (dstIndex > srcIndex)
                {
                    dstIndex--;
                }

                InputActionSerializationHelpers.MoveActionMap(m_SerializedObject, srcIndex, dstIndex);
                m_ApplyAction();
                DragAndDrop.AcceptDrag();
            }
            return(DragAndDropVisualMode.Move);
        }
예제 #14
0
        private DragAndDropVisualMode DragAndDropFromInside(DragAndDropArgs args)
        {
            if (args.parentItem?.depth != 0)
            {
                return(DragAndDropVisualMode.None);
            }

            if (!args.performDrop)
            {
                return(DragAndDropVisualMode.Move);
            }

            bool changed = false;

            foreach (string path in DragAndDrop.paths)
            {
                var importer = AssetImporter.GetAtPath(path);
                if (importer.assetBundleName == args.parentItem.displayName)
                {
                    continue;
                }
                importer.assetBundleName = args.parentItem.displayName;
                changed = true;
            }

            if (!changed)
            {
                return(DragAndDropVisualMode.None);
            }

            Reload();
            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 DragAndDropVisualMode HandleDragAndDrop(DragAndDropArgs args)
    {
        if (args.dragAndDropPosition == DragAndDropPosition.OutsideItems)
        {
            return(DragAndDropVisualMode.Rejected);
        }

        if (args.performDrop)
        {
            if (DragAndDrop.objectReferences.Length > 0)
            {//this is dropping asset into tree
                if (!isPreview)
                {
                    return(DragAndDropVisualMode.Rejected); //can only drop asset in the file list, not the folder structure
                }
                designer.GetAllAssetsDependency(DragAndDrop.objectReferences);
            }
            else
            {//this is dropping item from tree
                TreeViewItem dropTarget = args.parentItem;

                if (dropTarget is AssetTreeViewItem)
                {
                    return(DragAndDropVisualMode.Rejected);
                }


                for (int i = 0; i < m_Dragged.Count; ++i)
                {
                    TreeViewItem      itm       = FindItem(m_Dragged[i], rootItem);
                    AssetTreeViewItem assetItem = itm as AssetTreeViewItem;

                    if (assetItem != null)
                    {
                        string filename    = System.IO.Path.GetFileName(assetItem.fullAssetPath);
                        string newFilename = GetFullPath(dropTarget) + "/" + filename;

                        designer.currentlyEdited.outputPath[assetItem.dependencyIdx] = newFilename;
                    }
                    else
                    {
                        string originPath = GetFullPath(itm.parent);
                        string targetPath = GetFullPath(dropTarget);

                        for (int j = 0; j < itm.children.Count; ++j)
                        {
                            ReparentAssets(itm.children[j], originPath, targetPath);
                        }
                    }
                }

                designer.PopulateTreeview();
            }
        }

        return(DragAndDropVisualMode.Move);
    }
예제 #17
0
        protected override DragAndDropVisualMode HandleDragAndDrop(DragAndDropArgs args)
        {
            if (!CheckDropInDepsFolder(args))
            {
                return(DragAndDropVisualMode.Rejected);
            }

            return(base.HandleDragAndDrop(args));
        }
예제 #18
0
        protected override DragAndDropVisualMode HandleDragAndDrop(DragAndDropArgs args)
        {
            if (!args.performDrop)
            {
                return(DragAndDropVisualMode.Move);
            }

            return(DragAndDropVisualMode.Move);
        }
예제 #19
0
        protected override DragAndDropVisualMode HandleDragAndDrop(DragAndDropArgs args)
        {
            // remove item which came from category.
            var draggedCategory = DragAndDrop.GetGenericData("UnityEditorMemoCategoryDragging");

            if (draggedCategory != null)
            {
                return(DragAndDropVisualMode.None);
            }

            var draggedMemo = DragAndDrop.GetGenericData("UnityEditorMemoDragging");

            if (draggedMemo != null)
            {
                //var draggedItem = draggedMemo as List<TreeViewItem>;
                switch (args.dragAndDropPosition)
                {
                case DragAndDropPosition.BetweenItems:
                {
                    //var validDrag = isValidDrag( args.parentItem, draggedItem );
                    //if ( args.performDrop && validDrag )
                    //    OnDropDraggedElementsAtIndex( draggedItem, ( TreeViewItem )args.parentItem, args.insertAtIndex == -1 ? 0 : args.insertAtIndex );

                    return(DragAndDropVisualMode.None);
                }

                    //case DragAndDropPosition.OutsideItems:
                    //    {
                    //        if ( args.performDrop )
                    //            OnDropDraggedElementsAtIndex( draggedItem, rootItem, 1 );

                    //        return DragAndDropVisualMode.Move;
                    //    }
                }
            }
            else
            {
                // asset dragging
                switch (args.dragAndDropPosition)
                {
                case DragAndDropPosition.UponItem:
                {
                    if (args.performDrop)
                    {
                        UndoHelper.EditorMemoUndo(UndoHelper.UNDO_MEMO_EDIT);
                        var target = (TreeViewItem <UnityEditorMemo>)args.parentItem;
                        target.data.ObjectRef = new UnityEditorMemoObject(DragAndDrop.objectReferences[0]);
                        RefreshCustomRowHeights();
                    }
                    return(DragAndDropVisualMode.Move);
                }
                }
            }

            return(DragAndDropVisualMode.None);
        }
        protected bool IsValidDragDrop(DragAndDropArgs args)
        {
            //can't drag onto none or >1 bundles
            if (m_SourceBundles.Count == 0 || m_SourceBundles.Count > 1)
            {
                return(false);
            }

            //can't drag nothing
            if (DragAndDrop.paths == null || DragAndDrop.paths.Length == 0)
            {
                return(false);
            }

            //can't drag into a folder
            var folder = m_SourceBundles[0] as AssetBundleModel.BundleFolderInfo;

            if (folder != null)
            {
                return(false);
            }

            var data = m_SourceBundles[0] as AssetBundleModel.BundleDataInfo;

            if (data == null)
            {
                return(false); // this should never happen.
            }
            var thing = DragAndDrop.GetGenericData("AssetListTreeSource") as AssetListTree;

            if (thing != null)
            {
                return(false);
            }

            if (data.IsEmpty())
            {
                return(true);
            }

            if (data.isSceneBundle)
            {
                return(false);
            }


            foreach (var assetPath in DragAndDrop.paths)
            {
                if (AssetDatabase.GetMainAssetTypeAtPath(assetPath) == typeof(SceneAsset))
                {
                    return(false);
                }
            }

            return(true);
        }
예제 #21
0
        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);
        }
예제 #22
0
    protected override DragAndDropVisualMode HandleDragAndDrop(DragAndDropArgs args)
    {
        Object[] draggedObjects = DragAndDrop.objectReferences;
        Debug.LogFormat("pos: {0}\nindex: {1}\nparent: {2}\ndrop:{3}\nobjs: {4}",
                        args.dragAndDropPosition, args.insertAtIndex, args.parentItem, args.performDrop, draggedObjects);

        if (draggedObjects != null && draggedObjects.Length > 0)
        {
            switch (args.dragAndDropPosition)
            {
            case DragAndDropPosition.UponItem:
            case DragAndDropPosition.BetweenItems:
            {
                // bool validDrag = ValidDrag(args.parentItem, entryObjects);
                if (args.performDrop)
                {
                    var parentData = ((TreeViewItem <RollEntry>)args.parentItem).data;
                    if (draggedObjects.Length > 1)
                    {
                        TableModel.AddObjectsToTree(draggedObjects, parentData, args.insertAtIndex);
                    }
                    else
                    {
                        TableModel.AddObjectToTree(draggedObjects.First(), parentData, args.insertAtIndex);
                    }
                }
                return(DragAndDropVisualMode.Move);    //: DragAndDropVisualMode.None;
            }

            case DragAndDropPosition.OutsideItems:
            {
                if (args.performDrop)
                {
                    var parentData = m_TreeModel.root;
                    if (draggedObjects.Length > 1)
                    {
                        TableModel.AddObjectsToTree(draggedObjects, parentData, 0);
                    }
                    else
                    {
                        TableModel.AddObjectToTree(draggedObjects.First(), parentData, 0);
                    }
                }
                return(DragAndDropVisualMode.Move);
            }

            default:
                Debug.LogError("Unhandled enum " + args.dragAndDropPosition);
                return(DragAndDropVisualMode.None);
            }
        }

        return(base.HandleDragAndDrop(args));
    }
예제 #23
0
 protected override DragAndDropVisualMode HandleDragAndDrop(DragAndDropArgs args)
 {
     if (args.parentItem == null || args.parentItem.depth == -1)
     {
         return(DragAndDropVisualMode.Rejected);
     }
     else
     {
         return(base.HandleDragAndDrop(args));
     }
 }
        protected int FindDropAtIndex(DragAndDropArgs args)
        {
            int indexToDrop = args.insertAtIndex;

            // covers if(args.dragAndDropPosition == DragAndDropPosition.OutsideItems) and a safety check.
            if (indexToDrop < 0 || indexToDrop > rootItem.children.Count)
            {
                indexToDrop = rootItem.children.Count;
            }

            return(indexToDrop);
        }
예제 #25
0
            public DragAndDropData(DragAndDropArgs a)
            {
                args         = a;
                draggedNodes = DragAndDrop.GetGenericData("AssetBundleModel.BundleInfo") as List <AssetBundleModel.BundleInfo>;
                targetNode   = args.parentItem as AssetBundleModel.BundleTreeItem;
                paths        = DragAndDrop.paths;

                if (draggedNodes != null)
                {
                    foreach (var bundle in draggedNodes)
                    {
                        if ((bundle as AssetBundleModel.BundleFolderInfo) != null)
                        {
                            hasBundleFolder = true;
                        }
                        else
                        {
                            var dataBundle = bundle as AssetBundleModel.BundleDataInfo;
                            if (dataBundle != null)
                            {
                                if (dataBundle.isSceneBundle)
                                {
                                    hasScene = true;
                                }
                                else
                                {
                                    hasNonScene = true;
                                }

                                if ((dataBundle as AssetBundleModel.BundleVariantDataInfo) != null)
                                {
                                    hasVariantChild = true;
                                }
                            }
                        }
                    }
                }
                else if (DragAndDrop.paths != null)
                {
                    foreach (var assetPath in DragAndDrop.paths)
                    {
                        if (AssetDatabase.GetMainAssetTypeAtPath(assetPath) == typeof(SceneAsset))
                        {
                            hasScene = true;
                        }
                        else
                        {
                            hasNonScene = true;
                        }
                    }
                }
            }
예제 #26
0
        private void MoveAction(DragAndDropArgs args, ActionTreeViewItem row)
        {
            var action = (ActionTreeItem)row;

            var dstIndex = args.insertAtIndex;
            var srcIndex = action.index;

            if (dstIndex > srcIndex)
            {
                dstIndex--;
            }
            InputActionSerializationHelpers.MoveAction(actionMapProperty, srcIndex, dstIndex);
        }
예제 #27
0
        protected override DragAndDropVisualMode HandleDragAndDrop(DragAndDropArgs args)
        {
            var data = DragAndDrop.GetGenericData(typeof(StringTreeViewItem).FullName) as StringTreeViewItem;

            if (data == null)
            {
                return(DragAndDropVisualMode.None);
            }

            if (args.performDrop)
            {
                if (args.dragAndDropPosition == DragAndDropPosition.OutsideItems)
                {
                    data.RemoveField();
                    ((StringTreeViewItem)rootItem).DropItemAt(rootItem.children.Count - 1, data);
                    DragAndDrop.AcceptDrag();
                }
                else if (args.dragAndDropPosition == DragAndDropPosition.BetweenItems)
                {
                    var parent = args.parentItem as StringTreeViewItem;
                    var index  = args.insertAtIndex;

                    // fix index when dragging within a single object
                    if (parent.children.Contains(data) && parent.children.IndexOf(data) < index)
                    {
                        index--;
                    }

                    data.RemoveField();
                    parent.DropItemAt(index, data);
                    DragAndDrop.AcceptDrag();
                }
                else if (args.dragAndDropPosition == DragAndDropPosition.UponItem)
                {
                    var parent = args.parentItem.parent as StringTreeViewItem;
                    var index  = args.parentItem.parent.children.IndexOf(args.parentItem);

                    // fix index when dragging within a single object
                    if (parent.children.Contains(data) && parent.children.IndexOf(data) < index)
                    {
                        index--;
                    }

                    data.RemoveField();
                    parent.DropItemAt(index, data);
                    DragAndDrop.AcceptDrag();
                }
            }

            return(DragAndDropVisualMode.Move);
        }
예제 #28
0
        private DragAndDropVisualMode DoHandleSingleObjectDrop <TObject>(DragAndDropArgs args, TObject o, int offset)
        {
            var handler = HierarchyDragAndDrop <TObject, Key> .SingleObjectDrop;

            if (null == handler)
            {
                return(DragAndDropVisualMode.Rejected);
            }

            var item = GetDragAndDropItem(args);

            var             result     = DragAndDropVisualMode.Rejected;
            ISceneGraphNode resultNode = null;

            if (item is SceneItem sceneItem)
            {
                if (null != (resultNode = handler(m_Session, o, sceneItem.Graph, null,
                                                  args.dragAndDropPosition == DragAndDropPosition.BetweenItems ? args.insertAtIndex : -1)))
                {
                    IdsToExpand.Add(sceneItem.id);
                    result = DragAndDropVisualMode.Link;
                }
            }

            if (item is EntityItem entityItem)
            {
                var node = entityItem.Node;
                if (null != (resultNode = handler(m_Session, o, node.Graph as SceneGraph, node,
                                                  args.dragAndDropPosition == DragAndDropPosition.BetweenItems ? args.insertAtIndex : -1)))
                {
                    IdsToExpand.Add(entityItem.id);
                    result = DragAndDropVisualMode.Link;
                }
            }

            if (null == resultNode)
            {
                return(DragAndDropVisualMode.Rejected);
            }

            if (result == DragAndDropVisualMode.Link)
            {
                if (resultNode is EntityNode entityNode)
                {
                    EntityHierarchyWindow.SelectOnNextPaint(entityNode.Guid);
                }
            }

            return(result);
        }
예제 #29
0
        private bool CheckDropInDepsFolder(DragAndDropArgs args)
        {
            DragAndDropData data   = new DragAndDropData(args);
            var             parent = (data.args.parentItem as AssetBundleModel.BundleTreeItem);

            if (parent != null)
            {
                if (parent.bundle.m_Name.bundleName.StartsWith(AssetBundleConfig.AssetBundlesDepsDir))
                {
                    return(true);
                }
            }
            return(false);
        }
예제 #30
0
 protected override DragAndDropVisualMode HandleDragAndDrop(DragAndDropArgs args)
 {
     if (IsValidDragAndDrop())
     {
         if (args.performDrop)
         {
             foreach (var obj in DragAndDrop.objectReferences)
             {
                 AddAsset(obj);
             }
         }
         return(DragAndDropVisualMode.Copy);
     }
     return(DragAndDropVisualMode.Rejected);
 }