Beispiel #1
0
    private void Grab(GameObject iGrabbedObject)
    {
        if (iGrabbedObject == null)
        {
            return;
        }

        m_CurrentManipulatedObject = iGrabbedObject;

        VRActor vrActorScript = m_CurrentManipulatedObject.GetComponent <VRActor>();

        m_ObjectPreviousSyncDir     = vrActorScript.SyncDirection;
        vrActorScript.SyncDirection = MVRNodesMapper.ENodesSyncDirection.MiddleVRToUnity;
        vrNode3D middleVRNode = vrActorScript.GetMiddleVRNode();

        m_it.SetManipulatedNode(middleVRNode);
        m_it.SetPivotPositionVirtualWorld(MVRTools.FromUnity(m_CurrentManipulatedObject.GetComponent <Collider>().bounds.center));

        // Save initial position
        m_ObjectInitialLocalPosition = m_CurrentManipulatedObject.transform.localPosition;
        m_ObjectInitialLocalRotation = m_CurrentManipulatedObject.transform.localRotation;

        // Deactivate selection during the manipulation
        vrInteraction selection = MiddleVR.VRInteractionMgr.GetActiveInteractionByTag("ContinuousSelection");

        if (selection != null)
        {
            m_PausedSelection = selection;
            MiddleVR.VRInteractionMgr.Deactivate(m_PausedSelection);
        }

        // Hide Wand
        m_VRMgr.ShowWandGeometry(false);
    }
    private void Grab(GameObject iGrabbedObject)
    {
        m_CurrentManipulatedObject = iGrabbedObject;

        m_it.SetManipulatedNode(AcquireGameObjectNode(m_CurrentManipulatedObject, "InteractionManipulationHomerNode"));
        m_it.SetPivotPositionVirtualWorld(MVRTools.FromUnity(m_CurrentManipulatedObject.GetComponent <Collider>().bounds.center));

        // Pause rigidbody acceleration
        Rigidbody manipulatedRigidbody = iGrabbedObject.GetComponent <Rigidbody>();

        if (manipulatedRigidbody != null)
        {
            m_ManipulatedObjectInitialIsKinematic = manipulatedRigidbody.isKinematic;
            manipulatedRigidbody.isKinematic      = true;
        }

        // Deactivate selection during the manipulation
        vrInteraction selection = MiddleVR.VRInteractionMgr.GetActiveInteractionByTag("ContinuousSelection");

        if (selection != null)
        {
            m_PausedSelection = selection;
            MiddleVR.VRInteractionMgr.Deactivate(m_PausedSelection);
        }

        // Hide Wand
        m_VRMgr.ShowWandGeometry(false);
    }