void OnDragUpdated(DragUpdatedEvent e) { var stencil = Store.GetState().CurrentGraphModel.Stencil; var dragNDropHandler = stencil.DragNDropHandler; dragNDropHandler?.HandleDragUpdated(e, DragNDropContext.Blackboard); e.StopPropagation(); }
void OnDragUpdatedEvent(DragUpdatedEvent e) { var selection = DragAndDrop.GetGenericData("DragSelection") as List<ISelectable>; if (selection == null) { SetDragIndicatorVisible(false); return; } if (selection.Any(t => !(t is VFXBlackboardCategory))) { SetDragIndicatorVisible(false); return; } Vector2 localPosition = e.localMousePosition; m_InsertIndex = InsertionIndex(localPosition); if (m_InsertIndex != -1) { float indicatorY = 0; if (m_InsertIndex == childCount) { if (childCount > 0) { VisualElement lastChild = this[childCount - 1]; indicatorY = lastChild.ChangeCoordinatesTo(this, new Vector2(0, lastChild.layout.height + lastChild.resolvedStyle.marginBottom)).y; } else { indicatorY = this.contentRect.height; } } else { VisualElement childAtInsertIndex = this[m_InsertIndex]; indicatorY = childAtInsertIndex.ChangeCoordinatesTo(this, new Vector2(0, -childAtInsertIndex.resolvedStyle.marginTop)).y; } SetDragIndicatorVisible(true); m_DragIndicator.style.top = indicatorY - m_DragIndicator.resolvedStyle.height * 0.5f; DragAndDrop.visualMode = DragAndDropVisualMode.Move; } else { SetDragIndicatorVisible(false); } e.StopPropagation(); }
void DragUpdate(DragUpdatedEvent evt) { foreach (UnityEngine.Object obj in DragAndDrop.objectReferences) { if (!IsInAcceptedTypes(obj.GetType())) { continue; } DragAndDrop.visualMode = droppable ? DragAndDropVisualMode.Link : DragAndDropVisualMode.Rejected; evt.StopPropagation(); } }
void OnDragUpdated(DragUpdatedEvent evt) { Vector2 mousePosition = m_BlockContainer.WorldToLocal(evt.mousePosition); int blockIndex = GetDragBlockIndex(mousePosition); if (DragAndDrop.GetGenericData("DragSelection") != null) { IEnumerable <VFXBlockUI> blocksUI = (DragAndDrop.GetGenericData("DragSelection") as List <ISelectable>).Select(t => t as VFXBlockUI).Where(t => t != null); DragAndDrop.visualMode = evt.ctrlKey ? DragAndDropVisualMode.Copy : DragAndDropVisualMode.Move; DraggingBlocks(blocksUI, blockIndex); if (!m_DragStarted) { // TODO: Do something on first DragUpdated event (initiate drag) m_DragStarted = true; AddToClassList("dropping"); } else { // TODO: Do something on subsequent DragUpdated events } } 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.visualMode = DragAndDropVisualMode.Link; evt.StopPropagation(); DraggingBlocks(Enumerable.Empty <VFXBlockUI>(), blockIndex); if (!m_DragStarted) { // TODO: Do something on first DragUpdated event (initiate drag) m_DragStarted = true; AddToClassList("dropping"); } } } } }
protected void OnDragUpdatedEvent(DragUpdatedEvent evt) { var draggedObjects = DragAndDrop.GetGenericData("DragSelection") as List <IGraphElementModel>; if (!CanAcceptDrop(draggedObjects)) { HideDragIndicator(); return; } m_InsertIndex = InsertionIndex(evt.localMousePosition); if (m_InsertIndex != -1) { float indicatorY; if (m_InsertIndex == childCount) { VisualElement lastChild = this[m_InsertIndex - 1]; indicatorY = lastChild.ChangeCoordinatesTo(this, new Vector2(0, lastChild.layout.height + lastChild.resolvedStyle.marginBottom)).y; } else { VisualElement childAtInsertIndex = this[m_InsertIndex]; indicatorY = childAtInsertIndex.ChangeCoordinatesTo(this, new Vector2(0, -childAtInsertIndex.resolvedStyle.marginTop)).y; } ShowDragIndicator(indicatorY); DragAndDrop.visualMode = DragAndDropVisualMode.Move; } else { HideDragIndicator(); } evt.StopPropagation(); }
private void OnDragUpdatedEvent(DragUpdatedEvent evt) { var selection = DragAndDrop.GetGenericData("DragSelection") as List <ISelectable>; if (!CanAcceptDrop(selection)) { SetDragIndicatorVisible(false); return; } VisualElement sourceItem = null; foreach (ISelectable selectedElement in selection) { sourceItem = selectedElement as VisualElement; if (sourceItem == null) { continue; } } if (!Contains(sourceItem)) { SetDragIndicatorVisible(false); return; } Vector2 localPosition = evt.localMousePosition; m_InsertIndex = InsertionIndex(localPosition); if (m_InsertIndex != -1) { float indicatorY = 0; if (m_InsertIndex == childCount) { VisualElement lastChild = this[childCount - 1]; indicatorY = lastChild.ChangeCoordinatesTo(this, new Vector2(0, lastChild.layout.height + lastChild.resolvedStyle.marginBottom)).y; } else { VisualElement childAtInsertIndex = this[m_InsertIndex]; indicatorY = childAtInsertIndex.ChangeCoordinatesTo(this, new Vector2(0, -childAtInsertIndex.resolvedStyle.marginTop)).y; } SetDragIndicatorVisible(true); m_DragIndicator.layout = new Rect(0, indicatorY - m_DragIndicator.layout.height / 2, layout.width, m_DragIndicator.layout.height); } else { SetDragIndicatorVisible(false); m_InsertIndex = -1; } if (m_InsertIndex != -1) { DragAndDrop.visualMode = DragAndDropVisualMode.Move; } evt.StopPropagation(); }
private void OnDragUpdatedEvent(DragUpdatedEvent evt) { var selection = DragAndDrop.GetGenericData("DragSelection") as List <ISelectable>; if (selection == null) { SetDragIndicatorVisible(false); return; } if (selection.Any(t => !(t is VFXBlackboardField))) { SetDragIndicatorVisible(false); return; } Vector2 localPosition = evt.localMousePosition; m_InsertIndex = InsertionIndex(localPosition); if (m_InsertIndex != -1) { float indicatorY = 0; if (m_InsertIndex == childCount) { if (childCount > 0) { VisualElement lastChild = this[childCount - 1]; indicatorY = lastChild.ChangeCoordinatesTo(this, new Vector2(0, lastChild.layout.height + lastChild.style.marginBottom)).y; } else { indicatorY = this.contentRect.height; } } else { VisualElement childAtInsertIndex = this[m_InsertIndex]; indicatorY = childAtInsertIndex.ChangeCoordinatesTo(this, new Vector2(0, -childAtInsertIndex.style.marginTop)).y; } SetDragIndicatorVisible(true); m_DragIndicator.layout = new Rect(0, indicatorY - m_DragIndicator.layout.height / 2, layout.width, m_DragIndicator.layout.height); } else { SetDragIndicatorVisible(false); m_InsertIndex = -1; } if (m_InsertIndex != -1) { DragAndDrop.visualMode = evt.ctrlKey ? DragAndDropVisualMode.Copy : DragAndDropVisualMode.Move; } evt.StopPropagation(); }