Draw GL Lines in world Space

I have worldpsace Vector3 coordinates and try to draw lines using the GL functions.
This is my code:

	private void OnRenderObject(){
		_mat.SetPass(0);
		
		GL.PushMatrix();
        GL.LoadProjectionMatrix(Camera.main.projectionMatrix);
		GL.MultMatrix(Camera.main.worldToCameraMatrix);
		
		foreach(KeyValuePair<Color, List<Vector3>> entry in _lines)
		{
			List<Vector3> vertices = entry.Value;
			if(vertices.Count>0){
				_mat.SetColor("_Color", entry.Key);
				GL.Begin(GL.LINES);
				for(int i=0; i<vertices.Count; i+=2){
					GL.Vertex(vertices*);*
  •  			GL.Vertex(vertices[i+1]);*
    
  •  		}*
    
  •  		GL.End();*
    
  •  		vertices.Clear();*
    
  •  	}*
    
  •  }*
    

GL.PopMatrix();

  • }*
    While the lines do get rendered and I can recognize their shape, they are not properly placed on screen and somehow distorted. The problem must be related to the Matrices I’m using, but it looks correct to me (first the projectionMatrix is loaded, then the worldToCameraMatrix is multiplied. The material shader is really simple, just outputting a constant red color. What am I missing?

Instead of doing:

        GL.LoadProjectionMatrix(Camera.main.projectionMatrix);
       GL.MultMatrix(Camera.main.worldToCameraMatrix);

Try doing this instead:

GL.MultMatrix (transform.localToWorldMatrix);

The transform should be the object your trying to render the lines on. or the parent of the object so it has a reference in world space.