Beispiel #1
0
        protected virtual void ToggleRigidbody(Collider collider, bool state)
        {
            if (isEnabled || !state)
            {
                if (activateTrackedCollider)
                {
                    VRTK_ControllerTrackedCollider trackedCollider = collider.GetComponentInParent <VRTK_ControllerTrackedCollider>();
                    if (trackedCollider != null)
                    {
                        trackedCollider.ToggleColliders(state);
                        EmitEvent(state, trackedCollider.interactTouch);
                    }
                }

                if (activateInteractTouch)
                {
                    VRTK_InteractTouch touch = collider.GetComponentInParent <VRTK_InteractTouch>();
                    if (touch != null)
                    {
                        touch.ToggleControllerRigidBody(state, state);
                        EmitEvent(state, touch);
                    }
                }
            }
        }
Beispiel #2
0
    void Awake()
    {
        MakeSingleton();

        CurrentGameMode = GameMode.BUILD;

        /* Setup Controller Events */
        RightControllerEvents.SubscribeToButtonAliasEvent(VRTK.VRTK_ControllerEvents.ButtonAlias.TriggerPress, true, RightControllerEvents_TriggerDown);
        RightControllerEvents.SubscribeToButtonAliasEvent(VRTK.VRTK_ControllerEvents.ButtonAlias.TriggerPress, false, RightControllerEvents_TriggerUp);
        RightControllerEvents.SubscribeToButtonAliasEvent(VRTK.VRTK_ControllerEvents.ButtonAlias.GripPress, true, RightControllerEvents_GripDown);
        RightControllerEvents.SubscribeToButtonAliasEvent(VRTK.VRTK_ControllerEvents.ButtonAlias.GripPress, false, RightControllerEvents_GripUp);
        RightControllerEvents.SubscribeToButtonAliasEvent(VRTK.VRTK_ControllerEvents.ButtonAlias.TouchpadPress, false, RightControllerEvents_TouchpadUp);

        LeftControllerEvents.SubscribeToButtonAliasEvent(VRTK.VRTK_ControllerEvents.ButtonAlias.TriggerPress, true, LeftControllerEvents_TriggerDown);
        LeftControllerEvents.SubscribeToButtonAliasEvent(VRTK.VRTK_ControllerEvents.ButtonAlias.TriggerPress, false, LeftControllerEvents_TriggerUp);
        LeftControllerEvents.SubscribeToButtonAliasEvent(VRTK.VRTK_ControllerEvents.ButtonAlias.GripPress, false, LeftControllerEvents_GripUp);

        /* Setup Controller VRTK scripts */
        VRTK.VRTK_InteractGrab rightInteractGrab = RightControllerEvents.GetComponent <VRTK.VRTK_InteractGrab>();
        rightInteractGrab.grabButton = VRTK.VRTK_ControllerEvents.ButtonAlias.TriggerPress;

        RightInteractNearTouch = RightControllerEvents.GetComponent <VRTK.VRTK_InteractNearTouch>();
        RightInteractTouch     = RightControllerEvents.GetComponent <VRTK.VRTK_InteractTouch>();
        RightInteractGrab      = RightControllerEvents.GetComponent <VRTK.VRTK_InteractGrab>();

        RightAnimator = RightControllerEvents.gameObject.GetComponentInChildren <HandAnimator>();
        LeftAnimator  = LeftControllerEvents.gameObject.GetComponentInChildren <HandAnimator>();
    }
Beispiel #3
0
        protected virtual void OnEnable()
        {
            interactTouch    = GetComponent <VRTK_InteractTouch>();
            controllerEvents = GetComponent <VRTK_ControllerEvents>();

            ManageUseListener(true);
        }
        protected virtual void ToggleRigidbody(Collider collider, bool state)
        {
            VRTK_InteractTouch touch = collider.GetComponentInParent <VRTK_InteractTouch>();

            if (touch != null && (isEnabled || !state))
            {
                touch.ToggleControllerRigidBody(state, state);
                EmitEvent(state, touch);
            }
        }
Beispiel #5
0
        protected virtual void OnEnable()
        {
            interactTouch    = GetComponent <VRTK_InteractTouch>();
            controllerEvents = GetComponent <VRTK_ControllerEvents>();

            RegrabUndroppableObject();
            ManageGrabListener(true);
            ManageInteractTouchListener(true);
            SetControllerAttachPoint();
        }
Beispiel #6
0
        // Token: 0x060010EF RID: 4335 RVA: 0x00063A7C File Offset: 0x00061C7C
        protected virtual void ToggleRigidbody(Collider collider, bool state)
        {
            VRTK_InteractTouch componentInParent = collider.GetComponentInParent <VRTK_InteractTouch>();

            if (componentInParent != null && (this.isEnabled || !state))
            {
                componentInParent.ToggleControllerRigidBody(state, state);
                this.EmitEvent(state, componentInParent);
            }
        }
        protected virtual void OnEnable()
        {
            animator          = GetComponent <Animator>();
            controllerEvents  = (controllerEvents != null ? controllerEvents : GetComponentInParent <VRTK_ControllerEvents>());
            interactNearTouch = (interactNearTouch != null ? interactNearTouch : GetComponentInParent <VRTK_InteractNearTouch>());
            interactTouch     = (interactTouch != null ? interactTouch : GetComponentInParent <VRTK_InteractTouch>());
            interactGrab      = (interactGrab != null ? interactGrab : GetComponentInParent <VRTK_InteractGrab>());
            interactUse       = (interactUse != null ? interactUse : GetComponentInParent <VRTK_InteractUse>());

            controllerReference = VRTK_ControllerReference.GetControllerReference(controllerEvents.gameObject);
        }
 protected override void ControllerReady(VRTK_ControllerReference controllerReference)
 {
     if (VRTK_ControllerReference.IsValid(controllerReference))
     {
         VRTK_InteractTouch foundTouch = controllerReference.scriptAlias.GetComponentInChildren <VRTK_InteractTouch>();
         if (interactTouchToIgnore.Contains(foundTouch))
         {
             disableControllerCollidersRoutine = StartCoroutine(DisableControllerColliderAtEndOfFrame(foundTouch));
         }
     }
 }
Beispiel #9
0
        private void Awake()
        {
            if (GetComponent <VRTK_InteractTouch>() == null)
            {
                Debug.LogError("VRTK_InteractUse is required to be attached to a SteamVR Controller that has the VRTK_InteractTouch script attached to it");
                return;
            }

            interactTouch     = GetComponent <VRTK_InteractTouch>();
            controllerActions = GetComponent <VRTK_ControllerActions>();
        }
        private void Awake()
        {
            if (GetComponent<VRTK_InteractTouch>() == null)
            {
                Debug.LogError("VRTK_InteractUse is required to be attached to a SteamVR Controller that has the VRTK_InteractTouch script attached to it");
                return;
            }

            interactTouch = GetComponent<VRTK_InteractTouch>();
            controllerActions = GetComponent<VRTK_ControllerActions>();
        }
Beispiel #11
0
 protected virtual void OnEnable()
 {
     nearTouchedObjects.Clear();
     interactTouch = (interactTouch != null ? interactTouch : GetComponentInParent <VRTK_InteractTouch>());
     if (interactTouch != null)
     {
         CreateNearTouchCollider();
         interactTouch.ControllerStartTouchInteractableObject += ControllerStartTouchInteractableObject;
         interactTouch.ControllerUntouchInteractableObject    += ControllerUntouchInteractableObject;
     }
 }
Beispiel #12
0
        protected virtual void Awake()
        {
            originalControllerAttachPoint = controllerAttachPoint;
            controllerEvents = (controllerEvents != null ? controllerEvents : GetComponentInParent <VRTK_ControllerEvents>());
            interactTouch    = (interactTouch != null ? interactTouch : GetComponentInParent <VRTK_InteractTouch>());
            if (interactTouch == null)
            {
                VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_NOT_INJECTED, "VRTK_InteractGrab", "VRTK_InteractTouch", "interactTouch", "the same or parent"));
            }

            VRTK_SDKManager.instance.AddBehaviourToToggleOnLoadedSetupChange(this);
        }
Beispiel #13
0
        // Token: 0x060010F0 RID: 4336 RVA: 0x00063AB4 File Offset: 0x00061CB4
        protected virtual void EmitEvent(bool state, VRTK_InteractTouch touch)
        {
            ControllerRigidbodyActivatorEventArgs e;

            e.touchingObject = touch;
            if (state)
            {
                this.OnControllerRigidbodyOn(e);
                return;
            }
            this.OnControllerRigidbodyOff(e);
        }
Beispiel #14
0
        protected virtual void OnEnable()
        {
            controllerEvents = (controllerEvents != null ? controllerEvents : GetComponentInParent <VRTK_ControllerEvents>());
            interactTouch    = (interactTouch != null ? interactTouch : GetComponentInParent <VRTK_InteractTouch>());
            interactGrab     = (interactGrab != null ? interactGrab : GetComponentInParent <VRTK_InteractGrab>());

            if (interactTouch == null)
            {
                VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_NOT_INJECTED, "VRTK_InteractUse", "VRTK_InteractTouch", "interactTouch", "the same or parent"));
            }

            ManageUseListener(true);
        }
Beispiel #15
0
        protected virtual void OnEnable()
        {
            animator          = GetComponent <Animator>();
            controllerEvents  = (controllerEvents != null ? controllerEvents : GetComponentInParent <VRTK_ControllerEvents>());
            interactNearTouch = (interactNearTouch != null ? interactNearTouch : GetComponentInParent <VRTK_InteractNearTouch>());
            interactTouch     = (interactTouch != null ? interactTouch : GetComponentInParent <VRTK_InteractTouch>());
            interactGrab      = (interactGrab != null ? interactGrab : GetComponentInParent <VRTK_InteractGrab>());
            interactUse       = (interactUse != null ? interactUse : GetComponentInParent <VRTK_InteractUse>());

            controllerReference = VRTK_ControllerReference.GetControllerReference(controllerEvents.gameObject);

            transform.localRotation = Quaternion.identity;
            transform.localPosition = -0.15f * Vector3.forward;
        }
Beispiel #16
0
        private void Awake()
        {
            // 获取需要的脚本
            if (GetComponent <VRTK_InteractTouch>() == null)
            {
                Debug.LogError("VRTK_InteractGrab is required to be attached to a SteamVR Controller that has the VRTK_InteractTouch script attached to it");
                return;
            }

            interactTouch     = GetComponent <VRTK_InteractTouch>();
            trackedController = GetComponent <SteamVR_TrackedObject>();
            controllerActions = GetComponent <VRTK_ControllerActions>();
            controllerEvents  = GetComponent <VRTK_ControllerEvents>();
        }
        private void Awake()
        {
            if (GetComponent <VRTK_InteractTouch>() == null)
            {
                Debug.LogError("VRTK_InteractGrab is required to be attached to a Controller that has the VRTK_InteractTouch script attached to it");
                return;
            }

            interactTouch     = GetComponent <VRTK_InteractTouch>();
            controllerActions = GetComponent <VRTK_ControllerActions>();
            controllerEvents  = GetComponent <VRTK_ControllerEvents>();

            grabbedObjectList = new List <GameObject>();
        }
Beispiel #18
0
        protected virtual void OnEnable()
        {
            controllerEvents = (controllerEvents != null ? controllerEvents : GetComponentInParent <VRTK_ControllerEvents>());
            interactTouch    = (interactTouch != null ? interactTouch : GetComponentInParent <VRTK_InteractTouch>());

            if (interactTouch == null)
            {
                VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_NOT_INJECTED, "VRTK_InteractGrab", "VRTK_InteractTouch", "interactTouch", "the same or parent"));
            }

            RegrabUndroppableObject();
            ManageGrabListener(true);
            ManageInteractTouchListener(true);
            SetControllerAttachPoint();
        }
Beispiel #19
0
 protected virtual void AttemptSecondaryGrab(VRTK_InteractableObject grabbableObject)
 {
     if (attemptSecondaryGrab)
     {
         SDK_BaseController.ControllerHand currentHand = VRTK_DeviceFinder.GetControllerHand(interactTouch.gameObject);
         VRTK_ControllerReference          oppositeControllerReference = VRTK_ControllerReference.GetControllerReference(VRTK_DeviceFinder.GetOppositeHand(currentHand));
         if (VRTK_ControllerReference.IsValid(oppositeControllerReference))
         {
             secondaryInteractTouch = (secondaryInteractTouch == null ? oppositeControllerReference.scriptAlias.GetComponentInChildren <VRTK_InteractTouch>() : secondaryInteractTouch);
             secondaryInteractGrab  = (secondaryInteractGrab == null ? oppositeControllerReference.scriptAlias.GetComponentInChildren <VRTK_InteractGrab>() : secondaryInteractGrab);
             secondaryInteractTouch.ForceStopTouching();
             secondaryInteractTouch.ForceTouch(grabbableObject.gameObject);
             secondaryInteractGrab.AttemptGrab();
         }
     }
 }
        protected virtual void ManageTouchCollision(VRTK_InteractTouch touchToIgnore, bool ignore)
        {
            Collider[] interactTouchColliders = touchToIgnore.ControllerColliders();
            VRTK_ControllerTrackedCollider trackedColliderValue = VRTK_SharedMethods.GetDictionaryValue(VRTK_ObjectCache.registeredTrackedColliderToInteractTouches, touchToIgnore);

            if (trackedColliderValue != null)
            {
                Collider[] trackedColliders = trackedColliderValue.TrackedColliders();
                interactTouchColliders = interactTouchColliders.Concat(trackedColliders).ToArray();
            }

            for (int touchCollidersIndex = 0; touchCollidersIndex < interactTouchColliders.Length; touchCollidersIndex++)
            {
                for (int localCollidersIndex = 0; localCollidersIndex < localColliders.Length; localCollidersIndex++)
                {
                    if (localColliders[localCollidersIndex] != null && interactTouchColliders[touchCollidersIndex] != null && !ShouldExclude(localColliders[localCollidersIndex].transform))
                    {
                        Physics.IgnoreCollision(localColliders[localCollidersIndex], interactTouchColliders[touchCollidersIndex], ignore);
                    }
                }
            }
        }
Beispiel #21
0
        protected virtual IEnumerator AutoGrab()
        {
            yield return(new WaitForEndOfFrame());

            interactTouch = (interactTouch != null ? interactTouch : GetComponentInParent <VRTK_InteractTouch>());
            interactGrab  = (interactGrab != null ? interactGrab : GetComponentInParent <VRTK_InteractGrab>());

            if (interactTouch == null)
            {
                VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_NOT_INJECTED, "VRTK_ObjectAutoGrab", "VRTK_InteractTouch", "interactTouch", "the same or parent"));
            }

            if (interactGrab == null)
            {
                VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_NOT_INJECTED, "VRTK_ObjectAutoGrab", "VRTK_InteractGrab", "interactGrab", "the same or parent"));
            }

            if (objectToGrab == null)
            {
                VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.NOT_DEFINED, "objectToGrab"));
                yield break;
            }

            while (interactGrab.controllerAttachPoint == null)
            {
                yield return(true);
            }

            bool grabbableObjectDisableState = objectToGrab.disableWhenIdle;

            if (objectIsPrefab)
            {
                objectToGrab.disableWhenIdle = false;
            }

            VRTK_InteractableObject grabbableObject = objectToGrab;

            if (alwaysCloneOnEnable)
            {
                ClearPreviousClone();
            }

            if (!interactGrab.GetGrabbedObject())
            {
                if (cloneGrabbedObject)
                {
                    if (previousClonedObject == null)
                    {
                        grabbableObject      = Instantiate(objectToGrab);
                        previousClonedObject = grabbableObject;
                    }
                    else
                    {
                        grabbableObject = previousClonedObject;
                    }
                }

                if (grabbableObject.isGrabbable && !grabbableObject.IsGrabbed())
                {
                    grabbableObject.transform.position = transform.position;
                    interactTouch.ForceStopTouching();
                    interactTouch.ForceTouch(grabbableObject.gameObject);
                    interactGrab.AttemptGrab();
                }
            }
            objectToGrab.disableWhenIdle    = grabbableObjectDisableState;
            grabbableObject.disableWhenIdle = grabbableObjectDisableState;
        }
Beispiel #22
0
 protected virtual void Awake()
 {
     interactTouch     = GetComponent <VRTK_InteractTouch>();
     controllerActions = GetComponent <VRTK_ControllerActions>();
     controllerEvents  = GetComponent <VRTK_ControllerEvents>();
 }
Beispiel #23
0
 private void Awake()
 {
     interactTouch     = GetComponent <VRTK_InteractTouch>();
     controllerActions = GetComponent <VRTK_ControllerActions>();
     controllerEvents  = GetComponent <VRTK_ControllerEvents>();
 }
        protected virtual IEnumerator DisableControllerColliderAtEndOfFrame(VRTK_InteractTouch touchToIgnore)
        {
            yield return(new WaitForEndOfFrame());

            ManageTouchCollision(touchToIgnore, true);
        }