UV mapping for odd shape Procedural Mesh(Runtime mesh)

Does anyone have an universal code for handling odd shape mesh’s UV? I couldnt get the math on how to map a 3d plane to a 2d vector coordinates.

There isn’t a ‘universal’ solution, as it depends what shape your mesh is and how you want it mapped to UV co-ordinates.

What kind of shape do you have?

Frankly speaking, i was hoping for an all rounder shapes UV unwrapping solution. Could be a triangle, a sphere, a cube, low poly mountain or even a humanoid. Just need each of the triangles in their normals direction to be sized accordingly in a UV tile. But i am lacking the math area to solve this.

Currently i have managed a simple cube like mapping which is pretty simple. But there are refinements to do even for this simple uv unwrap.