How do I calculate the UV's for a procedurally generated shape?

I’m creating a mesh via script, but apparently I need UV’s.

So two questions I guess: 1 - do I actually need UV’s if I’m just using a material and not a texture?

and 2 - how do I procedurally generate the UV’s for an irregular shape? I have a feeling this is a very complex problem but I just don’t know…

1 - no you shouldn’t, just be sure to use a shader that doesn’t expect a texture and you should be fine

2 - yes arbitrarily mapping UVs to a polygonal shape is a somewhat complex, but well known problem . You need to "unwrap’ the shape and make a (mostly) topologically equivalent plane of polygons from it.

See http://forum.devmaster.net/t/uvw-unwrap-algorithms/21409

The UnityEditor namespace holds functionality to easily unwrap a mesh and generate UVs via scripting.

Have a look at UnityEditor.Unwrapping.GeneratePerTriangleUV(…) and UnityEditor.Unwrapping.GenerateSecondaryUVSet(…)

Remember, that these can only be used in the Unity editor and not runtime in your app/game.