protected void Update() { if (IsActive()) { // Retrieve selection result VRSelection selection = m_Wand.GetSelection(); if (selection == null || !selection.SelectedObject.GetComponent<VRActor>().Grabable) { return; } m_CurrentSelectedObject = selection.SelectedObject; // Manipulation if (m_it.HasManipulationStarted()) { // Try to grab Grab(m_CurrentSelectedObject); } else if (m_it.IsManipulationStopped()) { if (m_MustReleaseOwnership) { MiddleVR.VRNetMgr.RequestReleaseOwnership(m_CurrentManipulatedObject); m_MustReleaseOwnership = false; m_NetAcquisitionRequest = null; } Ungrab(); } else if (m_NetAcquisitionRequest != null) { if (m_NetAcquisitionRequest.IsFinished()) { m_NetAcquisitionRequest = null; if (MiddleVR.VRNetMgr.CanManipulateObject(m_CurrentSelectedObject)) { ContinueGrab(m_CurrentSelectedObject); } } } else if (m_it.IsManipulationRunning() && m_CurrentManipulatedObject != null) { // Nothing to do here } } }
private void Grab(GameObject iGrabbedObject) { if (iGrabbedObject == null) { return; } // Save initial position m_ManipulatedObjectInitialLocalPosition = iGrabbedObject.transform.localPosition; m_ManipulatedObjectInitialLocalRotation = iGrabbedObject.transform.localRotation; if (MiddleVR.VRNetMgr.CanManipulateObject(iGrabbedObject)) { ContinueGrab(iGrabbedObject); } else if (MiddleVR.VRNetMgr.CanAcquireObjectOwnership(iGrabbedObject)) { m_NetAcquisitionRequest = MiddleVR.VRNetMgr.RequestAcquireOwnership(iGrabbedObject); m_MustReleaseOwnership = true; } }