ShouldStartDrag() private static method

private static ShouldStartDrag ( Vector2 pressPos, Vector2 currentPos, float threshold, bool useDragThreshold ) : bool
pressPos Vector2
currentPos Vector2
threshold float
useDragThreshold bool
return bool
 protected virtual void ProcessDrag(PointerEventData pointerEvent)
 {        /*	used in StandaloneInputModule.ProcessToucheEvents() and StandaloneInputModule.ProcessMouseEvent(int id)
           *     call OnBeginDrag
           *     call OnPointerUp, if for some reason pointerPress != pointerDrag
           *     call OnDrag
           */
     if (pointerEvent.IsPointerMoving() && Cursor.lockState != CursorLockMode.Locked && !(pointerEvent.pointerDrag == null))
     {
         if (!pointerEvent.dragging && PointerInputModule.ShouldStartDrag(pointerEvent.pressPosition, pointerEvent.position, (float)base.eventSystem.pixelDragThreshold, pointerEvent.useDragThreshold))
         {
             ExecuteEvents.Execute <IBeginDragHandler>(pointerEvent.pointerDrag, pointerEvent, ExecuteEvents.beginDragHandler);
             pointerEvent.dragging = true;
         }
         if (pointerEvent.dragging)
         {
             if (pointerEvent.pointerPress != pointerEvent.pointerDrag)
             {
                 ExecuteEvents.Execute <IPointerUpHandler>(pointerEvent.pointerPress, pointerEvent, ExecuteEvents.pointerUpHandler);
                 pointerEvent.eligibleForClick = false;
                 pointerEvent.pointerPress     = null;
                 pointerEvent.rawPointerPress  = null;
             }
             ExecuteEvents.Execute <IDragHandler>(pointerEvent.pointerDrag, pointerEvent, ExecuteEvents.dragHandler);
         }
     }
 }
Example #2
0
        /// <summary>
        ///
        /// <para>
        /// Process the drag for the current frame with the given pointer event.
        /// </para>
        ///
        /// </summary>
        /// <param name="pointerEvent"/>
        protected virtual void ProcessDrag(PointerEventData pointerEvent)
        {
            bool flag = pointerEvent.IsPointerMoving();

            if (flag && (Object)pointerEvent.pointerDrag != (Object)null && (!pointerEvent.dragging && PointerInputModule.ShouldStartDrag(pointerEvent.pressPosition, pointerEvent.position, (float)this.eventSystem.pixelDragThreshold, pointerEvent.useDragThreshold)))
            {
                ExecuteEvents.Execute <IBeginDragHandler>(pointerEvent.pointerDrag, (BaseEventData)pointerEvent, ExecuteEvents.beginDragHandler);
                pointerEvent.dragging = true;
            }
            if (!pointerEvent.dragging || !flag || !((Object)pointerEvent.pointerDrag != (Object)null))
            {
                return;
            }
            if ((Object)pointerEvent.pointerPress != (Object)pointerEvent.pointerDrag)
            {
                ExecuteEvents.Execute <IPointerUpHandler>(pointerEvent.pointerPress, (BaseEventData)pointerEvent, ExecuteEvents.pointerUpHandler);
                pointerEvent.eligibleForClick = false;
                pointerEvent.pointerPress     = (GameObject)null;
                pointerEvent.rawPointerPress  = (GameObject)null;
            }
            ExecuteEvents.Execute <IDragHandler>(pointerEvent.pointerDrag, (BaseEventData)pointerEvent, ExecuteEvents.dragHandler);
        }