Exemplo n.º 1
0
    void Update()
    {
        Frame frame                  = m_LeapService.CurrentFrame;
        bool  bHasHandsInScene       = frame.Hands.Count > 0;
        bool  bControllerIsConnected = m_LeapService.IsConnected();

        m_iNumberOfHands = frame.Hands.Count;

        if (bHasHandsInScene && bControllerIsConnected)
        {
            foreach (Hand hand in frame.Hands)
            {
                if (hand.IsLeft)
                {
                    m_LeftDetection.SetHand(hand);

                    m_LeftFingerCollision.transform.position = m_LeftDetection.GetFinger(EFinger.eIndex).GetTipPosition();

                    m_bLeftIsVisible = true;

                    m_LeftFingerCollision.SetActive(true);

                    if (m_iNumberOfHands == 1)
                    {
                        m_bRightIsVisible = false;
                        m_RightFingerCollision.SetActive(false);
                    }
                }
                else
                {
                    m_RightDetection.SetHand(hand);

                    m_RightFingerCollision.transform.position = m_RightDetection.GetFinger(EFinger.eIndex).GetTipPosition();

                    m_bRightIsVisible = true;

                    m_RightFingerCollision.SetActive(true);

                    if (m_iNumberOfHands == 1)
                    {
                        m_bLeftIsVisible = false;
                        m_LeftFingerCollision.SetActive(false);
                    }
                }
            }
        }
    }
    void UpdateHand(Hand hand)
    {
        if (hand.IsLeft)
        {
            m_LeftDetection.SetHand(hand);

            for (int i = 0; i < 5; i++)
            {
                EFinger SelectedFinger = EFinger.eThumb + i;

                if (m_LeftFingerCollisions.ContainsKey(SelectedFinger))
                {
                    m_LeftFingerCollisions[SelectedFinger].transform.position = m_LeftDetection.GetFinger(SelectedFinger).GetTipPosition();
                    m_LeftFingerCollisions[SelectedFinger].SetActive(true);
                }

                if (m_iNumberOfHands == 1)
                {
                    if (m_RightFingerCollisions.ContainsKey(SelectedFinger))
                    {
                        m_RightFingerCollisions[SelectedFinger].SetActive(false);
                    }
                }
            }

            m_bLeftIsVisible = true;

            if (m_iNumberOfHands == 1)
            {
                m_bRightIsVisible = false;
            }
        }
        else
        {
            m_RightDetection.SetHand(hand);

            for (int i = 0; i < 5; i++)
            {
                EFinger SelectedFinger = EFinger.eThumb + i;

                if (m_RightFingerCollisions.ContainsKey(SelectedFinger))
                {
                    m_RightFingerCollisions[SelectedFinger].transform.position = m_RightDetection.GetFinger(SelectedFinger).GetTipPosition();
                    m_RightFingerCollisions[SelectedFinger].SetActive(true);
                }

                if (m_iNumberOfHands == 1)
                {
                    if (m_LeftFingerCollisions.ContainsKey(SelectedFinger))
                    {
                        m_LeftFingerCollisions[SelectedFinger].SetActive(false);
                    }
                }
            }

            m_bRightIsVisible = true;

            if (m_iNumberOfHands == 1)
            {
                m_bLeftIsVisible = false;
            }
        }
    }