Setting points of EdgeCollider2D results in wrong coordinates


first of all this is a 2D project and I am trying to set the points of an EdgeCollider2D via code, a component which is added to a Line gameobject, which mainly consists of a Line Renderer. Which I draw using my mouse from one object to another to connect those visually.

This happens at some places in my project, the very first one I am working on is this snippet here:

	void Update () {

		Vector3 mousePos = Camera.main.ScreenToWorldPoint (Input.mousePosition);
		mousePos.z = 0;

		if(circCol.bounds.Contains(mousePos)) {
			if (Manager.MouseLineRenderer) {
				Manager.MouseLineRenderer.SetPosition (1, this.transform.position);
				// Also set end point of Edge Collider
				Manager.MouseLineEdgeCollider.points[1] = new Vector2(this.transform.position.x, this.transform.position.y);

The line with Manager.MouseLineCollider… is the one I am working on right now and as it is right now, this ends up with this ending point (my Line only consists of 2 points and therefore also the EdgeCollider2D) appearing somewhere to the down right of where it should be. What’s more, this line does not seem to affect the EdgeCollider2D points at all since they always appear at the same position regardless how I draw the line.

Setting the Manager objects/references is done in another class, which is attached to the gameobjects, from which I start drawing the line:

	void OnMouseDrag () {

		line = newLineObj.GetComponent<Line>();

		line.originObject = this.gameObject;

		lineRenderer = newLineObj.gameObject.GetComponent<LineRenderer> ();

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

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

		Manager.MouseLineScript = newLineScript; // Set reference to current drawn line
		Manager.MouseLineRenderer = newLineRend;
		Manager.MouseLineEdgeCollider = newLineScript.gameObject.GetComponent<EdgeCollider2D> ();

What I want is this: points[1] should be set to the center point of this object (hence transform.position).

I guess this has to do with Worlspace/Screenspace/Camera but I don’t really understand what exactly I need to consider when doing such things.

Alright, I found out what the issue is thanks to @Jamora here:

I don’t fully understand how you are supposed to know that but apparently you can only alter the whole Vector2 array which is EdgeCollider2D.points but cannot modify the individual points directly.

Hence what I did was copy points to a temporary Vector2 array, modify the entries I want, and copy it back.