예제 #1
0
        //-------------------------------------------------
        private void HandHoverUpdate(Hand hand)
        {
            //Debug.Log(hand.gameObject.name + " Hover Update");

            GrabTypes startingGrabType = hand.GetGrabStarting();
            bool      isGrabStarting   = startingGrabType != GrabTypes.None;
            bool      isGrabbing       = hand.IsGrabbing();
            bool      isGrabEnding     = hand.IsGrabbingWithType(grabbedWithType) == false;


            if (isGrabStarting || (grabbingHand == null && isGrabbing))               // Grab Start
            //Debug.Log("    Grab Start! (" + Time.frameCount + ")");
            //if (grabbingHand != null) { // Another hand has already grabbed -> switch hands
            //	Debug.Log("    (switching hands)");
            //}

            {
                lastHandProjected = ComputeToTransformProjected(hand.hoverSphereTransform);

                if (hoverLock)
                {
                    hand.HoverLock(interactable);
                    handHoverLocked = hand;
                }

                driving         = true;
                grabbedWithType = hand.GetBestGrabbingType(GrabTypes.Grip);
                grabbingHand    = hand;
                isGrabEnding    = false;
            }
            else if (isGrabEnding && grabbingHand == hand)                 // Grab End
            //Debug.Log("    Grab End! (" + Time.frameCount + ")");

            {
                if (hoverLock)
                {
                    hand.HoverUnlock(interactable);
                    handHoverLocked = null;
                }

                driving         = false;
                grabbedWithType = GrabTypes.None;
                grabbingHand    = null;
            }

            if (grabbingHand == hand)
            {
                //Debug.Log("    Grab Update!");
                ComputeAngle(hand);
                UpdateAll();
            }
        }