public void AddVertex(Vector3 position) { GameObject vertex = vertexPool.GetObject(); vertex.transform.position = position; vertexes.Add(vertex); if (lastConnection != null) { GameObject connection = connectionPool.GetObject(); connection.GetComponent <ConnectionBehaviour>().CreateConnection(lastConnection.transform.position, vertex.transform.position); connections.Add(connection); } lastConnection = vertex; currentShape.AddPoint(position); }