private IEnumerator FindDevices()
    {
        yield return(new WaitForEndOfFrame());

        yield return(new WaitForEndOfFrame());

        yield return(new WaitForEndOfFrame());

        yield return(new WaitForEndOfFrame());

        HeadsetFollower = VRTK_DeviceFinder.HeadsetTransform().gameObject;
        RightHand       = VRTK_DeviceFinder.GetControllerRightHand().GetComponent <VRTK_ControllerEvents>();
        LeftHand        = VRTK_DeviceFinder.GetControllerLeftHand().GetComponent <VRTK_ControllerEvents>();

        RightHand.GetComponent <VRTK_ControllerEvents>().TriggerPressed   += TriggerPressed;
        LeftHand.GetComponent <VRTK_ControllerEvents>().TriggerPressed    += TriggerPressed;
        RightHand.GetComponent <VRTK_ControllerEvents>().GripPressed      += GripPressed;
        LeftHand.GetComponent <VRTK_ControllerEvents>().GripPressed       += GripPressed;
        RightHand.GetComponent <VRTK_ControllerEvents>().TouchpadPressed  += TouchpadPressed;
        LeftHand.GetComponent <VRTK_ControllerEvents>().TouchpadPressed   += TouchpadPressed;
        RightHand.GetComponent <VRTK_ControllerEvents>().ButtonTwoPressed += ButtonTwoPressed;
        LeftHand.GetComponent <VRTK_ControllerEvents>().ButtonTwoPressed  += ButtonTwoPressed;
        RightHand.GetComponent <VRTK_ControllerEvents>().StartMenuPressed += StartMenuPressed;
        LeftHand.GetComponent <VRTK_ControllerEvents>().StartMenuPressed  += StartMenuPressed;
    }
    private bool IsGrabValid()
    {
        var uiPointer = m_controllerEvents.GetComponent <VRTK_UIPointer>();

        if (uiPointer != null && uiPointer.hoveringElement != null)
        {
            return(false);
        }

        var touch = m_controllerEvents.GetComponent <VRTK_InteractTouch>();

        //Debug.LogError("VRTK_InteractTouch: " + touch);
        if (touch == null)
        {
            return(true);
        }
        var obj = touch.GetTouchedObject();

        //Debug.LogError("GetTouchedObject(): " + obj);
        if (obj == null)
        {
            return(true);
        }
        if (m_noGrabIfTouchingObject)
        {
            return(false);
        }
        var iObj = obj.GetComponent <VRTK_InteractableObject>();

        //Debug.LogError("VRTK_InteractableObject: " + iObj);
        if (iObj == null)
        {
            return(true);
        }
        //Debug.LogError("isGrabbable: " + iObj.isGrabbable);
        if (m_noGrabIfTouchingGrabbableObject)
        {
            return(!iObj.isGrabbable); // FIXME: iObj.isGrabbable returns incorrect value in build (not in editor)
        }
        return(false);
    }
Beispiel #3
0
 private void PointerStateValid(object sender, DestinationMarkerEventArgs e)
 {
     if (!valid)
     {
         events      = uiPointer.controllerEvents;
         interactUse = events.GetComponent <VRTK_InteractUse>();
         if (interactUse)
         {
             interactUse.enabled = false;
         }
         valid = true;
     }
 }
Beispiel #4
0
 void Awake()
 {
     leftHandTouch  = leftHand.GetComponent <VRTK_InteractTouch>();
     rightHandTouch = rightHand.GetComponent <VRTK_InteractTouch>();
 }