public void RemoveObject(GameObject leavingObject)
    // Removes parents if leavingObject
    {
        leavingObject.transform.parent = null;
        EnablePhysics(leavingObject);
        leavingObject.layer = 0;
        VRTK_ChildOfControllerGrabAttach grab = leavingObject.AddComponent <VRTK_ChildOfControllerGrabAttach>() as VRTK_ChildOfControllerGrabAttach;

        Destroy(leavingObject.GetComponent <VRTK_FixedJointGrabAttach>());
        grab.precisionGrab = true;
        leavingObject.GetComponent <ItemTracker>().SetUsable();
        waitRemove = false;
    }
 void DoRemoveObject(object sender, ControllerInteractionEventArgs e)
 // Removes parents if leavingObject
 {
     if (waitRemove == true)
     {
         leavingObject.transform.parent = null;
         EnablePhysics(leavingObject);
         VRTK_ChildOfControllerGrabAttach grab = leavingObject.AddComponent <VRTK_ChildOfControllerGrabAttach>() as VRTK_ChildOfControllerGrabAttach;
         Destroy(leavingObject.GetComponent <VRTK_FixedJointGrabAttach>());
         grab.precisionGrab = true;
         leavingObject.GetComponent <ItemTracker>().SetUsable();
         waitRemove = false;
     }
 }
Esempio n. 3
0
    private void ObjectSelectedHandler(GameObject selected)
    {
        GameObject instance = Instantiate <GameObject>(selected);
        VRTK_InteractableObject          interactible = instance.AddComponent <VRTK_InteractableObject>();
        VRTK_ChildOfControllerGrabAttach primary      = instance.AddComponent <VRTK_ChildOfControllerGrabAttach>();

        interactible.grabAttachMechanicScript = primary;
        primary.precisionGrab = true;
        VRTK_PrecisionScaleAction secondary = instance.AddComponent <VRTK_PrecisionScaleAction>();

        interactible.secondaryGrabActionScript = secondary;
        VRTK_MaterialColorSwapHighlighter highlighter = selected.AddComponent <VRTK_MaterialColorSwapHighlighter>();

        highlighter.customMaterial = highlighterMaterial;

        instance.transform.localScale = Vector3.one * 0.01f;
        instance.transform.position   = transform.position;
        instance.transform.rotation   = transform.rotation;
    }