private void OnDragPerformEvent(DragPerformEvent evt) { var selection = DragAndDrop.GetGenericData("DragSelection") as List <ISelectable>; if (selection == null) { SetDragIndicatorVisible(false); return; } if (selection.OfType <VFXBlackboardCategory>().Any()) { return; } if (m_InsertIndex != -1) { var parent = GetFirstAncestorOfType <VFXBlackboard>(); if (parent != null) { parent.OnMoveParameter(selection.OfType <VisualElement>().Select(t => t.GetFirstOfType <VFXBlackboardRow>()).Where(t => t != null), this, m_InsertIndex); } SetDragIndicatorVisible(false); evt.StopPropagation(); m_InsertIndex = -1; } }
void OnDragPerformEvent(DragPerformEvent e) { SetDragIndicatorVisible(false); var selection = DragAndDrop.GetGenericData("DragSelection") as List<ISelectable>; if (selection == null) { return; } var category = selection.OfType<VFXBlackboardCategory>().FirstOrDefault(); if (category == null) { return; } if (m_InsertIndex != -1) { if (m_InsertIndex > IndexOf(category)) --m_InsertIndex; controller.MoveCategory(category.title, m_InsertIndex - IndexOf(m_DefaultCategory) - 1); } SetDragIndicatorVisible(false); e.StopPropagation(); }
void OnDragPerform(DragPerformEvent e) { var stencil = Store.GetState().CurrentGraphModel.Stencil; var dragNDropHandler = stencil.DragNDropHandler; dragNDropHandler?.HandleDragPerform(e, Store, DragNDropContext.Blackboard, this); e.StopPropagation(); }
protected void OnDragPerformEvent(DragPerformEvent evt) { var selection = DragAndDrop.GetGenericData("DragSelection") as List <IGraphElementModel>; if (selection != null && CanAcceptDrop(selection) && m_InsertIndex != -1) { OnItemDropped(m_InsertIndex, selection); } HideDragIndicator(); evt.StopPropagation(); }
void OnDragPerform(DragPerformEvent evt) { RemoveDragIndicator(); if (DragAndDrop.GetGenericData("DragSelection") != null) { Vector2 mousePosition = m_BlockContainer.WorldToLocal(evt.mousePosition); IEnumerable <VFXBlockUI> blocksUI = (DragAndDrop.GetGenericData("DragSelection") as List <ISelectable>).Select(t => t as VFXBlockUI).Where(t => t != null); if (!CanDrop(blocksUI)) { return; } int blockIndex = GetDragBlockIndex(mousePosition); BlocksDropped(blockIndex, blocksUI, evt.ctrlKey); DragAndDrop.AcceptDrag(); m_DragStarted = false; RemoveFromClassList("dropping"); } else { var references = DragAndDrop.objectReferences.OfType <VisualEffectSubgraphBlock>(); if (references.Count() > 0 && (!controller.viewController.model.isSubgraph || !references.Any(t => t.GetResource().GetOrCreateGraph().subgraphDependencies.Contains(controller.viewController.model.subgraph) || t.GetResource() == controller.viewController.model))) { var context = references.First().GetResource().GetOrCreateGraph().children.OfType <VFXBlockSubgraphContext>().FirstOrDefault(); if (context != null && (context.compatibleContextType & controller.model.contextType) == controller.model.contextType) { DragAndDrop.AcceptDrag(); Vector2 mousePosition = m_BlockContainer.WorldToLocal(evt.mousePosition); int blockIndex = GetDragBlockIndex(mousePosition); VFXBlock newModel = ScriptableObject.CreateInstance <VFXSubgraphBlock>(); newModel.SetSettingValue("m_Subgraph", references.First()); controller.AddBlock(blockIndex, newModel); } evt.StopPropagation(); } } m_DragStarted = false; RemoveFromClassList("dropping"); }
void Drop(DragPerformEvent evt, Action <UnityEngine.Object, Vector2> OnDrop) { bool atLeastOneAccepted = false; foreach (UnityEngine.Object obj in DragAndDrop.objectReferences) { if (!IsInAcceptedTypes(obj.GetType())) { continue; } OnDrop.Invoke(obj, evt.localMousePosition); atLeastOneAccepted = true; } if (atLeastOneAccepted) { DragAndDrop.AcceptDrag(); evt.StopPropagation(); } }
private void OnDragPerformEvent(DragPerformEvent evt) { var selection = DragAndDrop.GetGenericData("DragSelection") as List <ISelectable>; if (!CanAcceptDrop(selection)) { SetDragIndicatorVisible(false); return; } if (m_InsertIndex != -1) { List <Tuple <VisualElement, VisualElement> > draggedElements = new List <Tuple <VisualElement, VisualElement> >(); foreach (ISelectable selectedElement in selection) { var draggedElement = selectedElement as VisualElement; if (draggedElement != null && Contains(draggedElement)) { draggedElements.Add(new Tuple <VisualElement, VisualElement>(FindSectionDirectChild(draggedElement), draggedElement)); } } if (draggedElements.Count == 0) { SetDragIndicatorVisible(false); return; } // Sorts the dragged elements from their relative order in their parent draggedElements.Sort((pair1, pair2) => { return(IndexOf(pair1.Item1).CompareTo(IndexOf(pair2.Item1))); }); int insertIndex = m_InsertIndex; foreach (Tuple <VisualElement, VisualElement> draggedElement in draggedElements) { VisualElement sectionDirectChild = draggedElement.Item1; int indexOfDraggedElement = IndexOf(sectionDirectChild); if (!((indexOfDraggedElement == insertIndex) || ((insertIndex - 1) == indexOfDraggedElement))) { if (blackboard.moveItemRequested != null) { blackboard.moveItemRequested(blackboard, m_InsertIndex, draggedElement.Item2); } else { if (insertIndex == contentContainer.childCount) { sectionDirectChild.BringToFront(); } else { sectionDirectChild.PlaceBehind(this[insertIndex]); } } } if (insertIndex > indexOfDraggedElement) // No need to increment the insert index for the next dragged element if the current dragged element is above the current insert location. { continue; } insertIndex++; } } SetDragIndicatorVisible(false); evt.StopPropagation(); }