Example #1
0
 private void DragFinish()
 {
     bDragStart = false;
     UnHook();
     if (ptMaxDiff.X > thresholdOfMaxDiff || ptMaxDiff.Y > thresholdOfMaxDiff)
     {
         DragMoved?.Invoke(this, new EventArgs());
     }
     else
     {
         DragCanceled?.Invoke(this, new EventArgs());
     }
 }
        private void Update()
        {
            if (_mouseDown)
            {
                // Check for drag release
                if (Input.GetMouseButtonUp(0))
                {
                    // Touch ended; cancel tracking
                    _mouseDown    = false;
                    _lastPosition = Vector3.zero;
                    if (DragEnded != null)
                    {
                        DragEnded.Invoke(Input.mousePosition);
                    }
                }
                else if (_lastPosition != Input.mousePosition)
                {
                    // Touch still occuring and moved
                    if (DragMoved != null)
                    {
                        DragMoved.Invoke(_lastPosition - Input.mousePosition);
                    }

                    _lastPosition = Input.mousePosition;
                }
            }
            else if (Input.GetMouseButtonDown(0))
            {
                // Otherwise, start tracking the first touch to begin
                _lastPosition = Input.mousePosition;
                _mouseDown    = true;

                if (DragBegan != null)
                {
                    DragBegan.Invoke(_lastPosition);
                }
            }
        }
Example #3
0
 protected virtual void OnDragMoved()
 {
     DragMoved?.Invoke(this, EventArgs.Empty);
 }