void UnlinkNodes() { Event current = Event.current; WaypointNode cNode = null; // Handles.DrawRectangle(ControlID, if (!current.alt) { Ray mRay = HandleUtility.GUIPointToWorldRay(current.mousePosition); RaycastHit rHit; if (Physics.Raycast(mRay, out rHit, Mathf.Infinity)) { cNode = currentWaypoints.GetClosestNode(rHit.point, 1.0f); } // Clear if right mouse is pressed. if (current.type == EventType.mouseDown && current.button == 1) { from = Vector3.zero; to = Vector3.zero; } if (cNode != null) { Handles.DrawWireDisc(cNode.Position, Vector3.up, 0.5f); if (current.type == EventType.mouseDown && current.button == 0 && from == Vector3.zero) // Mouse1 { from = cNode.Position; } else if (current.type == EventType.mouseDown && current.button == 0 && to == Vector3.zero) // Mouse1 and we have a from { if (cNode.Position != from) { to = cNode.Position; WaypointLink newLink = new WaypointLink(from, to); WaypointNode tempN = currentWaypoints.GetClosestNode(from); if (tempN != null) { if (tempN.Unlink(newLink)) { tempN = currentWaypoints.GetClosestNode(to); tempN.Unlink(newLink); cNode = null; from = to; to = Vector3.zero; } } else { cNode = null; from = Vector3.zero; to = Vector3.zero; Debug.LogError("Could not find node from list."); } } } } if (from != Vector3.zero) { Handles.DrawLine(from, rHit.point); } } }