I built a Random Generated Mini Game with SpriteShape Prefabs. The Random Generator moves and changes the Spline of the SpriteShape. But the Edge Collider 2D refreses its size only when I click on the Instantiated Prefab on the Hirarchy.
What can I do to Refresh the Collider
This is the Scene when the World just generated. All Colliders are on the left side.
This is the Scene after I clicked on the first 2 generated layers. The 2 Colliders Refreshed its size to the SpriteShape
This is our code:
GameObject currentLayer;
Spline spline;
int lastXPos = Random.Range(1, maxXPos-2);
currentLayer = Instantiate(layer);
currentLayer.transform.parent = gameObject.transform;
currentLayer.transform.localPosition = new Vector3(0,-(2+i*2));
spline = currentLayer.GetComponent<SpriteShapeController>().spline;
spline.SetPosition(0, new Vector3(0, 0));
spline.SetPosition(1, new Vector3(lastXPos, 0));