PolygonCollider2D edit problem

I have created a script that build a mesh which represents the fluid based on collider objects in the scene.To detect if this fluid touches anything i have to convert these mesh vertices to Polygoncollider so this way it would be able to detect 2d components when it collides but i have come across with an interesting problem.The problem is when a pull the vertices data and import it in the polygoncollider by using SetPath my fluid mesh object disappears at sometimes(in some frames).I check if it was a problem that environment based but its not here the things that i know about the problem

but first to clear things the objects which i have in my scene

  1. A game object that contains the mesh data
  2. A game object that contains polygonCollider component (apart from the mesh object)
  3. A gama object that contains my script which i use this script to create mesh and polygoncollider object seperately

Lets come to the things i know about the problem

  1. Problem disappears when i delete the line which holds to pass vertices to polygonCollider
  2. If i run the code my mesh appears and disappears like randomly
  3. I freezed to scene and checked the polygoncollider and when i checked the points array it was the same positions 1-360 all of them was the same.
  4. The identical positions was irrevelant from the actual positions, the positions when objects appears without a problem

And here my code part that runs the line that i pass mesh vertices to polygoncollider

		Triangulator _tr = new Triangulator (_collection); 
		Mesh _mesh = new Mesh();  
		_mesh.name = "MeshVolume"; 
		_mesh.vertices = Roveldo.convertDimension (_collection); 
		_mesh.triangles = _tr.Triangulate();  
		//_mesh.uv = _collection;
		_mesh.RecalculateBounds();
		_mesh.RecalculateNormals ();
		_obj.GetComponent<MeshFilter> ().mesh = _mesh; 
		border.GetComponent<PolygonCollider2D>().SetPath(0,_collection); // THE PROBLEM

*** If you dont have a clue to solve this would you help me with these things below ?***

  • If there is a way to detect meshcollider with 2d collider components.
  • If there is a better way to achive this other than colliders.

Well i solved the problem its silly that i forgot adding a layermask so when build polygoncollider the frame after his build rays collides with the polygonCollider i created.So there is no problem lies here.