Beispiel #1
0
        private void EndDragSession()
        {
            if (_activeDragSession != null)
            {
                _activeDragSession.End();
                _dragInfo.IsDragged = false;

                if (PreDragEnd != null)
                {
                    PreDragEnd(this, _dragInfo.HandleId);
                }
                foreach (var behaviour in _behaviours)
                {
                    if (behaviour.IsEnabled)
                    {
                        behaviour.OnGizmoDragEnd(_dragInfo.HandleId);
                    }
                }

                int dragHandleId = _dragInfo.HandleId;
                _dragInfo.Reset();

                if (PostDragEnd != null)
                {
                    PostDragEnd(this, dragHandleId);
                }
            }
            _activeDragSession = null;
        }
 public void SetDragSession(IGizmoDragSession dragSession)
 {
     foreach (var cap in _caps)
     {
         cap.DragSession = dragSession;
     }
 }
Beispiel #3
0
        private void TryActivateDragSession()
        {
            if (_hoveredHandle != null && _hoveredHandle.DragSession != null)
            {
                foreach (var behaviour in _behaviours)
                {
                    if (behaviour.IsEnabled)
                    {
                        if (!behaviour.OnGizmoCanBeginDrag(_hoveredHandle.Id))
                        {
                            return;
                        }
                    }
                }

                if (PreDragBeginAttempt != null)
                {
                    PreDragBeginAttempt(this, _hoveredHandle.Id);
                }
                foreach (var behaviour in _behaviours)
                {
                    if (behaviour.IsEnabled)
                    {
                        behaviour.OnGizmoAttemptHandleDragBegin(_hoveredHandle.Id);
                    }
                }
                if (PostDragBeginAttempt != null)
                {
                    PostDragBeginAttempt(this, _hoveredHandle.Id);
                }

                if (_hoveredHandle.DragSession.Begin())
                {
                    _activeDragSession = _hoveredHandle.DragSession;

                    _dragInfo.IsDragged       = true;
                    _dragInfo.DragChannel     = _activeDragSession.DragChannel;
                    _dragInfo.HandleDimension = _hoverInfo.HandleDimension;
                    _dragInfo.HandleId        = _hoverInfo.HandleId;
                    _dragInfo.DragBeginPoint  = _hoverInfo.HoverPoint;

                    if (PreDragBegin != null)
                    {
                        PreDragBegin(this, _dragInfo.HandleId);
                    }
                    foreach (var behaviour in _behaviours)
                    {
                        if (behaviour.IsEnabled)
                        {
                            behaviour.OnGizmoDragBegin(_dragInfo.HandleId);
                        }
                    }
                    if (PostDragBegin != null)
                    {
                        PostDragBegin(this, _dragInfo.HandleId);
                    }
                }
            }
        }
Beispiel #4
0
        public void SetDragChannel(GizmoDragChannel dragChannel)
        {
            _dragChannel = dragChannel;
            if (_dragChannel == GizmoDragChannel.Offset)
            {
                _selectedDragSession = _offsetDrag;
            }
            else if (_dragChannel == GizmoDragChannel.Rotation)
            {
                _selectedDragSession = _rotationDrag;
            }
            else if (_dragChannel == GizmoDragChannel.Scale)
            {
                _selectedDragSession = _scaleDrag;
            }

            Handle.DragSession = _selectedDragSession;
        }
Beispiel #5
0
 public void UnregisterTransformAsDragTarget(IGizmoDragSession dragSession)
 {
     dragSession.RemoveTargetTransform(_transform);
 }
Beispiel #6
0
 public void RegisterTransformAsDragTarget(IGizmoDragSession dragSession)
 {
     dragSession.AddTargetTransform(_transform);
 }