Transfer EdgeCollider2D points to world space


in my 2D project I am drawing lines to connect objects and use collisions. For this, whenever I draw a line, I also need to adjust the EdgeCollider2D of this LineRenderer object.

However, while I get the LineRenderer where it should be using the useWorldSpace property, I can’t figure out how to do the same with the EdgeCollider2D. Because although I give the collider the same positions for start and end point as the line itself, the collider appears slightly to the right, the position where the line would appear if useWorldSpace were disabled.

void OnMouseDrag () {

		Vector2 screenPos = new Vector2();
		Camera.main.ScreenToWorldPoint (screenPos);

		line.GetComponent<LineRenderer>().SetPosition (0,
			new Vector3 (transform.position.x + (GetComponent<SpriteRenderer>().bounds.size.x)/2,
		line.GetComponent<LineRenderer>().SetPosition (1, Camera.main.ScreenToWorldPoint(Input.mousePosition)+Vector3.forward*10);

		tempEdges = line.GetComponent<EdgeCollider2D> ().points;
		tempEdges [0] = new Vector2 (this.transform.position.x, this.transform.position.y);
		tempEdges [1] = new Vector2 (
			(Camera.main.ScreenToWorldPoint (Input.mousePosition) + Vector3.forward * 10).x,
			(Camera.main.ScreenToWorldPoint (Input.mousePosition) + Vector3.forward * 10).y);

		line.GetComponent<EdgeCollider2D> ().points = tempEdges;

Could you just add (or subtract, depending on which way you are going) the transforms.position of the gameObject to each point in the collider?