I am creating a random shape that is formed from placing points (3 or more points) on a plane (most of the time the plane is horizontal). After connecting these points, a closed shape is created (Polygon from points and lines).
I want to fill the inside area with a texture or a material.
I know I can create a mesh and a mesh renderer to show the material, but I am not sure how to create the mesh from vertices only. I have no idea how to make triangles of the mesh.
Edit 1: I found good answers from this question: Given an irregular polygon's vertex list, how to create internal triangles to build a flat 3D mesh efficiently? .
I am facing many problems with the solutions. Some methods work with convex and others with concave polygons.
Also, some solutions convert concave polygons to convex before getting triangles (it uses the convex-hull method to get boundaries).
Also when adding the material to the created mesh, it looks different than the original material. The small mesh at the middle of this image is the created mesh at runtime with the same material as the plane mesh on the background (plane mesh is created from the editor before running the application).
Is there a library or a plugin that handles the creation of the mesh by just passing to it an ordered list of vertices and a material?