public void MouseUp() { // finish drawing if (drawing == Tool.None && m_CurrentTool != Tool.Mesh) { return; } if (m_CurrentTool != Tool.Mesh && (m_CurrentTool != Tool.Volume || m_MeshForVolume == null)) { drawing = Tool.None; initialPosition = Vector3.zero; currentPosition = Vector3.zero; m_PointerController.DecreaseSizeOfPointer(); } // drag out switch (m_CurrentTool) { case Tool.Line: // TODO: change back m_DrawableLine.StopDrawing(m_SnapToGrid); break; case Tool.Area: // TODO: change back m_DrawableArea.StopDrawing(m_SnapToGrid); Destroy(m_LineForArea); break; case Tool.Volume: // if (m_VolumeCopy != null) // { if (m_MeshForVolume == null) { // TODO: change back m_DrawableVolume.StopDrawing(m_SnapToGrid); Destroy(m_AreaForVolume); } else { m_PointerController.DecreaseSizeOfPointer(); m_MeshForVolume.GetComponent <LightUpOnCollision>().SetEnabled(false); if (m_MeshCreatorController.m_SnapToGrid) { DrawVolume(true); } m_MeshForVolume = null; m_MeshCreatorController.FinishMesh(); m_PointerController.collidingObject = null; currentPosition = Vector3.zero; initialPosition = Vector3.zero; drawing = Tool.None; } break; case Tool.Sphere: m_DrawableSphere.StopDrawing(m_SnapToGrid); break; case Tool.Mesh: if (drawing != Tool.Mesh) // start drawing mesh { m_PointerController.IncreaseSizeOfPointer(); drawing = Tool.Mesh; initialPosition = m_Pointer.transform.position; m_MeshCopy = UnityEngine.Object.Instantiate(m_Mesh, initialPosition, Quaternion.identity, m_Parent.transform); m_MeshCreatorController = m_MeshCopy.GetComponent <MeshCreatorController>(); m_LineCopy = m_MeshCreatorController.AddLine(initialPosition); DrawMesh(); } else { // want to end current line and start new line unless we are back at the starting position // if m_MeshCreatorController.m_SnapToGrid is true, then the line should snap to a whole number plus the initial pos if (m_MeshCreatorController.m_SnapToGrid) { // last currentPosition should snap to the first initial position plus or minus a whole number DrawMesh(true); initialPosition = currentPosition; } else { initialPosition = m_Pointer.transform.position; } GameObject originalLine = m_MeshCreatorController.GetLine(0); if (originalLine.transform.Find("Sphere").gameObject.GetComponent <LightUpOnCollision>().collision) { m_PointerController.DecreaseSizeOfPointer(); // end mesh m_LineCopy = null; drawing = Tool.None; m_MeshCreatorController.CreateMesh(); m_MeshCreatorController.DeleteLines(); m_PointerController.UnrestrictPointerToInsideRays(); m_PointerController.isCentered = true; } else { // new line m_LineCopy = m_MeshCreatorController.AddLine(initialPosition); DrawMesh(); } } break; case Tool.None: default: break; } }