コード例 #1
0
        /// <summary>
        /// the ForceSnap method attempts to automatically attach a valid Interactable Object to the snap drop zone.
        /// </summary>
        /// <param name="objectToSnap">The Interactable Object to attempt to snap.</param>
        protected virtual void ForceSnap(VRTK_InteractableObject interactableObjectToSnap)
        {
            if (interactableObjectToSnap != null)
            {
                if (attemptTransitionAtEndOfFrameRoutine != null)
                {
                    StopCoroutine(attemptTransitionAtEndOfFrameRoutine);
                }

                if (checkCanSnapRoutine != null)
                {
                    StopCoroutine(checkCanSnapRoutine);
                }

                if (interactableObjectToSnap.IsGrabbed())
                {
                    interactableObjectToSnap.ForceStopInteracting();
                }

                if (gameObject.activeInHierarchy)
                {
                    attemptTransitionAtEndOfFrameRoutine = StartCoroutine(AttemptForceSnapAtEndOfFrame(interactableObjectToSnap));
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// the ForceSnap method attempts to automatically attach a valid game object to the snap drop zone.
        /// </summary>
        /// <param name="objectToSnap">The GameObject to attempt to snap.</param>
        public virtual void ForceSnap(GameObject objectToSnap)
        {
            VRTK_InteractableObject ioCheck = objectToSnap.GetComponentInParent <VRTK_InteractableObject>();

            if (ioCheck != null)
            {
                StopCoroutine("AttemptForceSnapAtEndOfFrame");
                if (ioCheck.IsGrabbed())
                {
                    ioCheck.ForceStopInteracting();
                }
                StartCoroutine(AttemptForceSnapAtEndOfFrame(ioCheck));
            }
        }
コード例 #3
0
        // Token: 0x060011F4 RID: 4596 RVA: 0x000679C4 File Offset: 0x00065BC4
        public virtual void ForceSnap(GameObject objectToSnap)
        {
            VRTK_InteractableObject componentInParent = objectToSnap.GetComponentInParent <VRTK_InteractableObject>();

            if (componentInParent != null)
            {
                componentInParent.SaveCurrentState();
                base.StopCoroutine("AttemptForceSnapAtEndOfFrame");
                if (componentInParent.IsGrabbed(null))
                {
                    componentInParent.ForceStopInteracting();
                    base.StartCoroutine(this.AttemptForceSnapAtEndOfFrame(objectToSnap));
                    return;
                }
                this.AttemptForceSnap(objectToSnap);
            }
        }
コード例 #4
0
 protected virtual void CheckUse(GameObject interactingObject)
 {
     if (useOnTouchWhen != AutoInteractions.Never && reuseTimer < Time.time)
     {
         VRTK_InteractUse interactUseScript = interactingObject.GetComponentInChildren <VRTK_InteractUse>();
         if (interactUseScript != null && (useOnTouchWhen == AutoInteractions.NoButtonHeld || (useOnTouchWhen == AutoInteractions.ButtonHeld && interactUseScript.IsUseButtonPressed())))
         {
             if (!interactableObject.holdButtonToUse && interactableObject.IsUsing())
             {
                 interactableObject.ForceStopInteracting();
             }
             else
             {
                 interactUseScript.AttemptUse();
             }
         }
     }
 }
コード例 #5
0
    void SetClip(GameObject clipObj, Collider other, bool fast = false)
    {
        if (isEmpty)
        {
            isEmpty = false;
            if (!fast)
            {
                doHack = true;
            }
            Collider collider = other;
            VRTK.VRTK_InteractableObject interaction = clipObj.GetComponent <VRTK.VRTK_InteractableObject>();
            Rigidbody body = clipObj.GetComponent <Rigidbody>();
            interaction.ForceStopInteracting();
            interaction.isGrabbable = false;
            // interaction.enabled = false;
            collider.enabled = false;
            originalPosition = clipObj.transform.localPosition;
            originalRotation = clipObj.transform.localRotation;
            if (!fast)
            {
                clipObj.transform.SetParent(newClipParent);
            }
            else
            {
                clipObj.transform.SetParent(currentClipParent);
            }
            clipObj.transform.localPosition = Vector3.zero;
            clipObj.transform.localRotation = Quaternion.identity;

            if (!fast)
            {
                clipChangeAnimator.SetTrigger("PutIn");
            }
            body.isKinematic = true;
            oldClip          = currentClip;
            currentClip      = clipObj;
            //  AkSoundEngine.PostEvent(removeClipEvent, soundEmitter);

            if (!fast)
            {
                StartCoroutine(OnClipChangeComplete());
            }
        }
        else
        {
            isEmpty = false;
            doHack  = true;
            Collider collider = other;
            VRTK.VRTK_InteractableObject interaction = clipObj.GetComponent <VRTK.VRTK_InteractableObject>();
            Rigidbody body = clipObj.GetComponent <Rigidbody>();
            interaction.ForceStopInteracting();
            interaction.isGrabbable = false;
            // interaction.enabled = false;
            collider.enabled = false;
            originalPosition = clipObj.transform.localPosition;
            originalRotation = clipObj.transform.localRotation;
            clipObj.transform.SetParent(newClipParent);
            clipObj.transform.localPosition = Vector3.zero;
            clipObj.transform.localRotation = Quaternion.identity;

            clipChangeAnimator.SetTrigger("Change");
            body.isKinematic = true;
            oldClip          = currentClip;
            currentClip      = clipObj;
            //  AkSoundEngine.PostEvent(removeClipEvent, soundEmitter);

            StartCoroutine(OnClipChangeComplete());
        }
    }