Exemple #1
0
    void DetectBothHands(Leap.Frame leapframe)
    {
        if (!LeapProvider.IsConnected())
        {
            PrimaryHand.Undetect();
            SecondaryHand.Undetect();
            return;
        }

        int primaryhandcount = 0, secondaryhandcount = 0;

        foreach (Leap.Hand hand in leapframe.Hands)
        {
            if ((hand.IsRight && User.IsRightHanded) || (hand.IsLeft && User.IsLeftHanded))
            {
                ++primaryhandcount;
                PrimaryHand.Detect(hand);
            }
            else if ((hand.IsRight && User.IsLeftHanded) || (hand.IsLeft && User.IsRightHanded))
            {
                ++secondaryhandcount;
                SecondaryHand.Detect(hand);
            }
        }
        if (primaryhandcount > 1)
        {
            Debug.LogWarning(primaryhandcount + " primary hands are detected.");
        }
        if (secondaryhandcount > 1)
        {
            Debug.LogWarning(secondaryhandcount + " secondary hands are detected.");
        }
        if (primaryhandcount == 0)
        {
            PrimaryHand.Undetect();
        }
        if (secondaryhandcount == 0)
        {
            SecondaryHand.Undetect();
        }
    }