void UpdatePerFinger()
    {
        for (int i = 0; i < FingerGestures.Instance.MaxFingers && i < MaxSimultaneousGestures; ++i)
        {
            FingerGestures.Finger finger = FingerGestures.GetFinger(i);
            T gesture = Gestures[i];

            FingerGestures.FingerList touches = tempTouchList;
            touches.Clear();

            if (finger.IsDown)
            {
                touches.Add(finger);
            }

            if (gesture.State == GestureRecognitionState.Ready)
            {
                if (CanBegin(gesture, touches))
                {
                    Begin(gesture, 0, touches);
                }
            }

            UpdateGesture(gesture, touches);
        }
    }
    void FingerGestures_OnFingerUp(int fingerIndex, Vector2 fingerPos, float timeHeldDown)
    {
        CheckSpawnParticles(fingerPos, fingerUpObject);

        // this shows how to access a finger object using its index
        // The finger object contains useful information not available through the event arguments that you might want to use
        FingerGestures.Finger finger = FingerGestures.GetFinger(fingerIndex);
        Debug.Log("Finger was lifted up at " + finger.Position + " and moved " + finger.DistanceFromStart.ToString("N0") + " pixels from its initial position at " + finger.StartPosition);
    }
Example #3
0
    protected virtual void InitFingerEventsList(int fingersCount)
    {
        fingerEventsList = new List <T>(fingersCount);

        for (int i = 0; i < fingersCount; ++i)
        {
            T e = CreateFingerEvent();
            e.Detector = this;
            e.Finger   = FingerGestures.GetFinger(i);
            fingerEventsList.Add(e);
        }
    }
Example #4
0
    // handle the fingerup event
    void OnFingerUpEvent(int fingerIndex, Vector2 fingerPos, float timeHeldDown)
    {
        // If hit UIObject, return donn't need dispose 3DObject
        if (Globals.Instance.MGUIManager.MIsHitUIObject)
        {
            // Dispose the event in UIObject rect
            foreach (IFingerEventListener listener in MUIObjectEventListenerList)
            {
                if (!listener.IsFingerEventActive())
                {
                    continue;
                }

                if (listener != null && listener.OnFingerUpEvent(fingerIndex, fingerPos, timeHeldDown))
                {
                    break;
                }
            }

            return;
        }

        // this shows how to access a finger object using its index
        // The finger object contains useful information not available through the event arguments that you might want to use
        FingerGestures.Finger finger = FingerGestures.GetFinger(fingerIndex);
        //Debug.Log( "Finger " + fingerIndex + " was held down for " + timeHeldDown.ToString( "N2" ) + " seconds" );
        // Debug.Log( "Finger was lifted up at " + finger.Position + " and moved " + finger.DistanceFromStart.ToString( "N0" ) + " pixels from its initial position at " + finger.StartPosition );

        foreach (IFingerEventListener listener in M3DEventListenerList)
        {
            if (!listener.IsFingerEventActive())
            {
                continue;
            }

            if (listener != null && listener.OnFingerUpEvent(fingerIndex, fingerPos, timeHeldDown))
            {
                //break;
            }
        }
    }
Example #5
0
    public void Update()
    {
        // already updated this frame, skip
        if (lastUpdateFrame == Time.frameCount)
        {
            return;
        }

        lastUpdateFrame = Time.frameCount;

        fingersAdded.Clear();
        fingersRemoved.Clear();

        for (int i = 0; i < FingerGestures.Instance.MaxFingers; ++i)
        {
            FingerGestures.Finger finger = FingerGestures.GetFinger(i);

            if (finger.IsDown)
            {
                // new touch?
                if (!finger.WasDown)
                {
                    //Debug.Log( "ADDED " + finger );
                    fingersAdded.Add(finger);
                }
            }
            else
            {
                // lifted off finger
                if (finger.WasDown)
                {
                    //Debug.Log( "REMOVED " + finger );
                    fingersRemoved.Add(finger);
                }
            }
        }

        // remove fingers from clusters
        foreach (FingerGestures.Finger finger in fingersRemoved)
        {
            // update active clusters
            for (int i = clusters.Count - 1; i >= 0; --i)
            {
                Cluster cluster = clusters[i];

                if (cluster.Fingers.Remove(finger))
                {
                    // retire clusters that no longer have any fingers left
                    if (cluster.Fingers.Count == 0)
                    {
                        //Debug.Log( "Recycling cluster " + cluster.Id );

                        // remove from active clusters list
                        clusters.RemoveAt(i);

                        // move back to pool
                        clusterPool.Add(cluster);
                    }
                }
            }
        }

        // add new fingers
        foreach (FingerGestures.Finger finger in fingersAdded)
        {
            // try to add finger to existing cluster
            Cluster cluster = FindExistingCluster(finger);

            // no valid active cluster found for that finger, create a new cluster
            if (cluster == null)
            {
                cluster           = NewCluster();
                cluster.StartTime = finger.StarTime;
                //Debug.Log( "Created NEW cluster " + cluster.Id + " for " + finger );
            }
            else
            {
                //Debug.Log( "Found existing cluster " + cluster.Id + " for " + finger );
            }

            // add finger to selected cluster
            cluster.Fingers.Add(finger);
        }
    }