private void OnCollapseFinished() { if (A.GetComponent <BranchHandle>() != null) { A.GetComponent <BranchHandle>().MergeRemainingCords(this); Destroy(A.gameObject); } else { Plug p = A.GetComponentInActor <Plug>(); if (p != null) { p.DestroyPlug(); } } if (B.GetComponent <BranchHandle>() != null) { B.GetComponent <BranchHandle>().MergeRemainingCords(this); Destroy(B.gameObject); } else { Plug p = B.GetComponentInActor <Plug>(); if (p != null) { p.DestroyPlug(); } } DestroyCord(); }
private void OnMergeButtonPressed(object sender, ControllerInteractionEventArgs e) { VRTK_InteractGrab grabbingController = e.controllerReference.actual.GetComponentInChildren <VRTK_InteractGrab>(); Plug grabbedPlug = grabbingController.GetGrabbedObject().GetComponent <Plug>(); Cord connectedCord = grabbedPlug.ConnectedCord; bool replaceCordStart = connectedCord.StartNode.Equals(grabbedPlug.CordAttachPoint); if (replaceCordStart) { connectedCord.Connect(transform, connectedCord.EndNode); if (connectedCord.EndNode.GetComponent <BranchHandle>() != null) { connectedCord.Flow = -1; } } else { connectedCord.Connect(connectedCord.StartNode, transform); if (connectedCord.StartNode.GetComponent <BranchHandle>() != null) { connectedCord.Flow = 1; } } branchNode = new CordNode(connectedCord, transform); grabbingController.ForceRelease(); grabbedPlug.DestroyPlug(); cordJunction = SplitCord(sourceCord); StopMovementAlongCord(); ConnectBranchToJunction(); }