/*
     * -----------------------
     * CheckStartDrag()
     * -----------------------
     */
    void CheckStartDrag(Event e)
    {
        if ((e.type == EventType.MouseDrag) && (e.button == 0))
        {
            for (int i = 0; i < items.size; i++)
            {
                if (items[i].rect.Contains(e.mousePosition))
                {
                    DragAndDrop.PrepareStartDrag();                    // reset data

                    CustomDragData dragData = new CustomDragData();
                    dragData.originalGroupIndex = selectedGroup;
                    dragData.originalIndex      = items[i].index;
                    dragData.originalProperty   = items[i].prop;

                    DragAndDrop.SetGenericData(dragDropIdentifier, dragData);

                    DragAndDrop.objectReferences = new Object[0];

                    DragAndDrop.StartDrag(dragData.originalProperty.FindPropertyRelative("name").stringValue);
                    e.Use();
                }
            }
        }
    }
    /*
     * -----------------------
     * UpdateDrag()
     * -----------------------
     */
    void UpdateDrag(Event e)
    {
        CustomDragData dragData = DragAndDrop.GetGenericData(dragDropIdentifier) as CustomDragData;

        if (dragData == null)
        {
            return;
        }

        int groupIndex = FindGroupIndex(e);

        switch (e.type)
        {
        case EventType.DragUpdated:
            if ((groupIndex >= 0) && (groupIndex != selectedGroup))
            {
                DragAndDrop.visualMode = DragAndDropVisualMode.Move;
            }
            else
            {
                DragAndDrop.visualMode = DragAndDropVisualMode.Rejected;
            }
            e.Use();
            break;

        case EventType.Repaint:
            if ((DragAndDrop.visualMode == DragAndDropVisualMode.None) ||
                (DragAndDrop.visualMode == DragAndDropVisualMode.Rejected))
            {
                break;
            }
            if (groupIndex >= 0 && groupIndex < groups.size)
            {
                EditorGUI.DrawRect(groups[groupIndex].rect, new Color(0f, 1f, 0f, 0.1f));
            }
            break;

        case EventType.DragPerform:
            DragAndDrop.AcceptDrag();
            // queue the sound FX move
            QueueSoundFXMove(dragData.originalGroupIndex, dragData.originalIndex, groupIndex);
            e.Use();
            break;

        case EventType.MouseUp:
            // in case MouseDrag never occurred:
            DragAndDrop.PrepareStartDrag();
            break;
        }
    }
Esempio n. 3
0
        //Handle drag drop of event groups.
        void DoDragDrop()
        {
            var currentEvent = Event.current;

            if (currentEvent.type == EventType.DragExited)
            {
                DragAndDrop.PrepareStartDrag();
            }

            var dragArea = DropAreas.Find(a => a.Area.Contains(currentEvent.mousePosition));
            var dragData = DragAndDrop.GetGenericData("DragItem") as CustomDragData;

            switch (currentEvent.type)
            {
            case EventType.MouseDown:
                if (dragArea != null)
                {
                    DragAndDrop.PrepareStartDrag();
                    var customDragData = new CustomDragData();
                    customDragData.Index = dragArea.Index;
                    DragAndDrop.SetGenericData("DragItem", customDragData);
                    Object[] objectRefs = new Object[0];
                    DragAndDrop.objectReferences = objectRefs;
                }
                currentEvent.Use();
                break;

            case EventType.MouseDrag:
                if (dragData != null)
                {
                    FoldedOut.Clear();
                    DragAndDrop.StartDrag(Bank.AudioEvents[dragData.Index].EventName);
                }
                DragAndDrop.visualMode = DragAndDropVisualMode.Move;
                currentEvent.Use();
                break;

            case EventType.DragUpdated:
                if (dragData != null && dragArea != null)
                {
                    if (dragArea.Index != dragData.Index)
                    {
                        DragAndDrop.visualMode = DragAndDropVisualMode.Move;
                    }
                    else
                    {
                        DragAndDrop.visualMode = DragAndDropVisualMode.Rejected;
                    }
                }
                currentEvent.Use();
                break;

            case EventType.Repaint:
                if (dragData != null && dragArea != null)
                {
                    if (DragAndDrop.visualMode == DragAndDropVisualMode.Move)
                    {
                        EditorGUI.DrawRect(dragArea.Area, Color.white);
                    }
                }
                // currentEvent.Use();
                break;

            case EventType.DragPerform:
                if (dragData != null && dragArea != null)
                {
                    if (dragArea.Index != dragData.Index)
                    {
                        InsertGroupBefore(dragData.Index, dragArea.Index);
                        DragAndDrop.AcceptDrag();
                    }
                }

                currentEvent.Use();
                break;

            case EventType.DragExited:
                currentEvent.Use();
                break;
            }
        }
Esempio n. 4
0
        //Handle drag drop of event groups.
        void DoDragDrop()
        {
            var currentEvent = Event.current;

            if(currentEvent.type==EventType.DragExited)
            {
                DragAndDrop.PrepareStartDrag();
            }

            var dragArea = DropAreas.Find(a=>a.Area.Contains(currentEvent.mousePosition));
            var dragData = DragAndDrop.GetGenericData("DragItem") as CustomDragData;

            switch(currentEvent.type)
            {
                case EventType.mouseDown:
                    if(dragArea!=null)
                    {
                        DragAndDrop.PrepareStartDrag();
                        var customDragData = new CustomDragData();
                        customDragData.Index = dragArea.Index;
                        DragAndDrop.SetGenericData("DragItem", customDragData);
                        Object[] objectRefs = new Object[0];
                        DragAndDrop.objectReferences = objectRefs;
                    }
                    currentEvent.Use();
                    break;
                    
                case EventType.mouseDrag:
                    if(dragData!=null)
                    {
                        FoldedOut.Clear();
                        DragAndDrop.StartDrag(Bank.AudioEvents[dragData.Index].EventName);
                    }
                    DragAndDrop.visualMode = DragAndDropVisualMode.Move;
                    currentEvent.Use();
                    break;
                case EventType.dragUpdated:
                    if(dragData!=null && dragArea!=null)
                    {
                        if(dragArea.Index!=dragData.Index)
                        {
                            DragAndDrop.visualMode = DragAndDropVisualMode.Move;
                        }
                        else
                        {
                            DragAndDrop.visualMode = DragAndDropVisualMode.Rejected;
                        }
                    }
                    currentEvent.Use();
                    break;
                case EventType.repaint:
                    if(dragData!=null && dragArea!=null)
                    {
                        if(DragAndDrop.visualMode==DragAndDropVisualMode.Move)
                        {
                            EditorGUI.DrawRect(dragArea.Area, Color.white);
                        }
                    }
                    currentEvent.Use();
                    break;
                case EventType.DragPerform:
                    if(dragData!=null && dragArea!=null)
                    {
                        if(dragArea.Index!=dragData.Index)
                        {
                            InsertGroupBefore(dragData.Index, dragArea.Index);
                            DragAndDrop.AcceptDrag();
                        }
                    }

                    currentEvent.Use();
                    break;

                case EventType.DragExited:
                    currentEvent.Use();
                    break;
            }
        }