How to create a line using two Vector3 points in unity?

Ok, I've figured it out by using LineRenderer like this:

var line: GameObject=GameObject.Find("/LineRenderer");
fence = Instantiate(line,Pos,Rotation);
fence.setPosition(0,p1);
fence.setPosition(1,p2);

Thanks for all of your answers above


//For creating line renderer object
lineRenderer = new GameObject("Line").AddComponent<LineRenderer>();
lineRenderer.startColor = Color.black;
lineRenderer.endColor = Color.black;
lineRenderer.startWidth = 0.01f;
lineRenderer.endWidth = 0.01f;
lineRenderer.positionCount = 2;
lineRenderer.useWorldSpace = true;    

//For drawing line in the world space, provide the x,y,z values
lineRenderer.SetPosition(0, new Vector3(x,y,z)); //x,y and z position of the starting point of the line
lineRenderer.SetPosition(1, new Vector3(x,y,z)); //x,y and z position of the starting point of the line