Exemple #1
0
        /// <summary>
        /// Release  everything snapped to us
        /// </summary>
        public void ReleaseAll()
        {
            // No need to keep checking
            if (HeldItem == null)
            {
                return;
            }

            // Still need to keep track of item if we can't fully drop it
            if (!CanDropItem && HeldItem != null)
            {
                trackedItem = HeldItem;
            }

            HeldItem.ResetScale();

            if (DisableColliders && disabledColliders != null)
            {
                foreach (var c in disabledColliders)
                {
                    if (c)
                    {
                        c.enabled = true;
                    }
                }
            }
            disabledColliders = null;

            HeldItem.enabled          = true;
            HeldItem.transform.parent = null;

            // Play Unsnap sound
            if (HeldItem != null)
            {
                if (SoundOnSnap)
                {
                    VRUtils.Instance.PlaySpatialClipAt(SoundOnUnsnap, transform.position, 0.75f);
                }

                // Call event
                if (OnDetachEvent != null)
                {
                    OnDetachEvent.Invoke(HeldItem);
                }
            }

            HeldItem = null;
        }
Exemple #2
0
        /// <summary>
        /// Release  everything snapped to us
        /// </summary>
        public void ReleaseAll()
        {
            // No need to keep checking
            if (HeldItem == null)
            {
                return;
            }

            // Still need to keep track of item if we can't fully drop it
            if (!CanDropItem && HeldItem != null)
            {
                trackedItem = HeldItem;
            }

            HeldItem.ResetScale();

            if (DisableColliders && disabledColliders != null)
            {
                foreach (var c in disabledColliders)
                {
                    if (c)
                    {
                        c.enabled = true;
                    }
                }
            }
            disabledColliders = null;

            // Reset Kinematic status
            if (heldItemRigid)
            {
                heldItemRigid.isKinematic = heldItemWasKinematic;
            }

            HeldItem.enabled          = true;
            HeldItem.transform.parent = null;

            // Play Unsnap sound
            if (HeldItem != null)
            {
                if (SoundOnSnap)
                {
                    VRUtils.Instance.PlaySpatialClipAt(SoundOnUnsnap, transform.position, 0.75f);
                }

                // Call event
                if (OnDetachEvent != null)
                {
                    OnDetachEvent.Invoke(HeldItem);
                }

                // Fire Off Grabbable Events
                GrabbableEvents[] ge = HeldItem.GetComponents <GrabbableEvents>();
                if (ge != null)
                {
                    for (int x = 0; x < ge.Length; x++)
                    {
                        ge[x].OnSnapZoneExit();
                    }
                }
            }

            HeldItem = null;
        }