Programmatically generate UV map

I have a sphere mesh I have imported into Unity; it is currently without a UV map. I need to programmatically generate a UV map for this sphere. I don’t suppose there’s an easy way to do this, is there? :?

Mesh mesh = ((MeshFilter)GetComponent (typeof (MeshFilter))).mesh;
Vector2[] uv = new Vector2[mesh.vertices.Length];
for (int i = 0; i < triangles.Length / 3; i++) {
    	uv[mesh.triangles[i * 3 + 0]] = new Vector2 (?,?);
    	uv[mesh.triangles[i * 3 + 1]] = new Vector2 (?,?);    
    	uv[mesh.triangles[i * 3 + 2]] = new Vector2 (?,?);  
}
mesh.uv = uv;

Something like that should do it. Don’t know what kind of mapping you want, but you have enough info there to calculate pretty much whatever you need per triangle. If you just want a spherical mapping, I would suggest doing that in a modeling tool then re-importing.