예제 #1
0
    protected override bool CanBegin(SwipeGesture gesture, FingerGestures.IFingerList touches)
    {
        if (!base.CanBegin(gesture, touches))
        {
            return(false);
        }

        if (touches.GetAverageDistanceFromStart() < 0.5f)
        {
            return(false);
        }

        // all touches must be moving
        if (!touches.AllMoving())
        {
            return(false);
        }

        // if multiple touches, make sure they're all going in roughly the same direction
        if (!touches.MovingInSameDirection(0.35f))
        {
            return(false);
        }

        return(true);
    }
예제 #2
0
    protected override bool CanBegin(DragGesture gesture, FingerGestures.IFingerList touches)
    {
        if (!base.CanBegin(gesture, touches))
        {
            return(false);
        }

        // must have moved beyond move tolerance threshold
        if (touches.GetAverageDistanceFromStart() < ToPixels(MoveTolerance))
        {
            return(false);
        }

        // all touches must be moving
        if (!touches.AllMoving())
        {
            return(false);
        }

        // if multiple touches, make sure they're all going in roughly the same direction
        if (RequiredFingerCount >= 2 && ApplySameDirectionConstraint && !touches.MovingInSameDirection(0.35f))
        {
            return(false);
        }

        return(true);
    }
    protected override bool CanBegin(DragGesture gesture, FingerGestures.IFingerList touches)
    {
        if (!base.CanBegin(gesture, touches))
        {
            return(false);
        }
        //若是在Ui层上滑动,false
        if (IsPointerOverUIObject())
        {
            return(false);
        }
        // must have moved beyond move tolerance threshold
        if (touches.GetAverageDistanceFromStart() < ToPixels(MoveTolerance))
        {
            return(false);
        }

        // all touches must be moving
        if (!touches.AllMoving())
        {
            return(false);
        }

        // if multiple touches, make sure they're all going in roughly the same direction
        if (RequiredFingerCount >= 2 && ApplySameDirectionConstraint && !touches.MovingInSameDirection(0.35f))
        {
            return(false);
        }
        //判断allPages是否有isActive为true
        foreach (var item in PageMgr.allPages.Values)
        {
            if (item.name == "UIParkPage" || item.name == "UIEntryPage" || item.name == "UIZooPage" || item.name == "UILoading" || item.name == "UIMapPage")
            {
                if (item.isActive() == true)
                {
                    return(false);
                }
            }
        }
        return(true);
    }
예제 #4
0
    protected override GestureRecognitionState OnRecognize(DragGesture gesture, FingerGestures.IFingerList touches)
    {
        if (touches.Count != RequiredFingerCount)
        {
            // fingers were lifted off
            if (touches.Count < RequiredFingerCount)
            {
                return(GestureRecognitionState.Ended);
            }

            return(GestureRecognitionState.Failed);
        }

        if (RequiredFingerCount >= 2 && ApplySameDirectionConstraint && touches.AllMoving() && !touches.MovingInSameDirection(0.35f))
        {
            return(GestureRecognitionState.Failed);
        }

        gesture.Position  = touches.GetAveragePosition();
        gesture.LastDelta = gesture.DeltaMove;
        gesture.DeltaMove = gesture.Position - gesture.LastPos;

        // if we are currently moving, or we were still moving last frame (allows listeners to detect when the finger is stationary when MoveDelta = 0)...
        if (gesture.DeltaMove.sqrMagnitude > 0 || gesture.LastDelta.sqrMagnitude > 0)
        {
            gesture.LastPos = gesture.Position;
        }

        RaiseEvent(gesture);
        return(GestureRecognitionState.InProgress);
    }
    protected override GestureRecognitionState OnRecognize(PinchRotateGesture gesture, FingerGestures.IFingerList touches)
    {
        if (touches.Count != RequiredFingerCount)
        {
            gesture.Delta = 0;

            // fingers were lifted?
            if (touches.Count < RequiredFingerCount)
            {
                return(GestureRecognitionState.Recognized);
            }

            // more fingers added, gesture failed
            return(GestureRecognitionState.Failed);
        }

        FingerGestures.Finger finger0 = touches[0];
        FingerGestures.Finger finger1 = touches[1];

        gesture.Position = 0.5f * (finger0.Position + finger1.Position);

        float curGap = Vector2.Distance(finger0.Position, finger1.Position);

        // dont do anything if both fingers arent moving
        if (!FingerGestures.AllFingersMoving(finger0, finger1))   // && curGap >= UnityEngine.Screen.width * 0.25f
        {
            return(GestureRecognitionState.InProgress);
        }


        float newDelta = FingerGestures.GetAdjustedPixelDistance(DeltaScale * (curGap - gesture.Gap));

        gesture.Gap = curGap;

        // if( Mathf.Abs( newDelta ) > 0.001f )
        {
            if (touches.AllMoving() && touches.MovingInSameDirection(0.35f))//&& curGap < UnityEngine.Screen.width*0.25f
            {
                EventMessageName = OnTwoFingerDrag;
                //Debug.Log("OnTwoFingerDrag rec");
                // skip without firing event
                // return GestureRecognitionState.InProgress;// GestureRecognitionState.InProgress; //TODO: might want to make this configurable, so the recognizer can fail if fingers move in same direction
            }
            else if (touches.AllMoving() && FingersMovedInOppositeDirections(finger0, finger1))
            {
                EventMessageName = EventOnPinch;
                //   Debug.Log("EventOnPinch rec");
            }
            else
            {
                //  Debug.Log("pinch rotate inProgress");
                return(GestureRecognitionState.InProgress);
            }
            gesture.LastDelta = gesture.DeltaMove;
            gesture.Delta     = newDelta;
            gesture.DeltaMove = gesture.Position - gesture.LastPos;

            // if we are currently moving, or we were still moving last frame (allows listeners to detect when the finger is stationary when MoveDelta = 0)...
            if (gesture.DeltaMove.sqrMagnitude > 0 || gesture.LastDelta.sqrMagnitude > 0)
            {
                gesture.LastPos = gesture.Position;
            }
            RaiseEvent(gesture);
        }

        return(GestureRecognitionState.InProgress);
    }