Beispiel #1
0
        public void Detach(bool fromAttachMethod = false)
        {
            //Debug.Log("Detach: " + this, gameObject);

            //TrackedPoseDriver approach
            {
                DestroyTrackedPoseDriver();
            }

            transform.DOKill();

            //SLOT
            //-------------------------------------------------
            if (!fromAttachMethod)
            {
                TryStore(OwnerHandVR);
            }
            //-------------------------------------------------

            OwnerHandVR.AttachedGrabbable = null;

            //not needed, the BelongState gives if it is attached, not need to check if ownerHandVR is null like before, so ownerHandVR mainstains the last ownerHandVR when state is changed until it is attached again
            //can be useful to return grabbable to last hand
            //OwnerHandVR = null;

            //if it has been attached to a slot
            if (Stored)
            {
                //Events
                OnDetached?.Invoke(OwnerHandVR);

#if UNITY_EDITOR
                Debug.Log("Dettached and Stored Grabbable: " + this + " from HandVR: " + OwnerHandVR, gameObject);
#endif

                return;
            }

            //TrackedPoseDriver approach
            {
                transform.position = /*OwnerHandVR.transform.position*/ OwnerHandVR.PoseProvider.AttachPosition;
                transform.rotation = /*OwnerHandVR.transform.rotation*/ OwnerHandVR.PoseProvider.AttachRotation;
            }

            transform.parent = null;

            AdjustPhysicsWithPhysicsTracker(OwnerHandVR);

            state = BelongState.Free;

            PhysicsExt.IgnoreCollisions(OwnerHandVR.CharacterVR.CharacterController, Colliders, false);                //Undo Ignore Collisions between this and CharacterVR

            //Events
            OnDetached?.Invoke(OwnerHandVR);

#if UNITY_EDITOR
            Debug.Log("Dettached Grabbable: " + this + " from HandVR: " + OwnerHandVR, gameObject);
#endif
        }
Beispiel #2
0
 /// <summary>
 /// Detaches the element from the host. Override <see cref="OnDetach"/>
 /// </summary>
 public void Detach()
 {
     if (IsAttached)
     {
         IsAttached = false;
         RenderCore.Detach();
         OnDetach();
         OnDetached?.Invoke(this, EventArgs.Empty);
     }
 }
Beispiel #3
0
 /// <summary>
 /// Detaches this instance.
 /// </summary>
 public void Detach()
 {
     if (IsAttached)
     {
         IsAttached = false;
         RenderCore.Detach();
         Disposer.RemoveAndDispose(ref bitmapCache);
         OnDetach();
         OnDetached?.Invoke(this, EventArgs.Empty);
     }
 }
 /// <summary>
 /// Detaches the element from the host. Override <see cref="OnDetach"/>
 /// </summary>
 public void Detach()
 {
     if (IsAttached)
     {
         IsAttached = false;
         InvalidateSceneGraph();
         RenderCore.Detach();
         OnDetach();
         DisposeAndClear();
         OnDetached?.Invoke(this, EventArgs.Empty);
     }
 }