Mesh position incorrect....

When clicked on collider, it will draw prodedural box mesh. But the position is wrong and it appear that the vertex position is local insteand of world position. How can i fix??

alt text

private void makeLine(Vector2 inputPos)
{
	if (!dragging && Mode == DragMode.MAKE_ICE && canDragSimu)
		{
     		Ray ray = cameraComp.ScreenPointToRay(new Vector3(inputPos.x,inputPos.y,0)); 
			RaycastHit hit;

			//if(Physics.Raycast(ray,out hit,50))

			if(Physics.Raycast(ray,out hit,150))
			{
				if(!hit.transform.CompareTag("NoIcePlaneArea"))
				{

					Vector3 hitPos = hit.point;

					Debug.Log("hit pos " + hitPos);

					iceLine = Instantiate(iceLineTemplate, new Vector3 (hitPos.x, hitPos.y,hitPos.z), Quaternion.identity) as GameObject;

					mesh = new Mesh(); 

					mfter = iceLine.AddComponent("MeshFilter") as MeshFilter;

					mrer = iceLine.AddComponent("MeshRenderer") as MeshRenderer;

				

					Transform parent = iceLine.transform;

					Vector3 topLeftFront = new Vector3(hitPos.x-1f,hitPos.y+1f,hitPos.z);            

					Vector3 topRightFront = new Vector3(hitPos.x+1f,hitPos.y+1f,hitPos.z);                 

					Vector3 bottomLeftFront = new Vector3(hitPos.x-1f,hitPos.y-1f,hitPos.z);       

					Vector3 bottomRightFront = new Vector3(hitPos.x+1f,hitPos.y-1f,hitPos.z);  

					newVertices = new Vector3[]{topLeftFront,topRightFront,bottomLeftFront,bottomRightFront};									

					newTriangles = new int[]{0,1,2,

											 2,1,3};

			   		mesh.vertices = newVertices;

					mesh.triangles = newTriangles;

					mesh.RecalculateBounds();

					mesh.RecalculateNormals();

					mesh.Optimize();

					mfter.sharedMesh = mesh;    

					mrer.sharedMaterial = customMat;

				    

					int i = mfter.sharedMesh.vertexCount;

					while(i>=0)

					{ 

					  Debug.LogError("vertex position : "+mfter.sharedMesh.vertices[i-1]);

					  i--;

					}				    
				}     	    
			}
		}
}

You instantiate your line at hitPos and then you set positions of vertices to hitPos, so you get double hitPos offset. Try instantiating object at Vector.zero.