Texturing a mesh generated by script

I have some trouble uv mapping and texturing my mesh. I really need help learning how this works. CobblestoneFoundation.cs - Pastebin.com
I tried to uv map sides but it is stretched and height texture doesn’t affect it. My script generates a 3d mesh from a 2d shape. I posted this a while ago but somehow it got deleted and I don’t know why.

Any help?