Cubemap cube = mySkyProbe.customBakedTexture as Cubemap;
int miplevel = 0;
int mipsize = cube.width;
for (; miplevel<cube.mipmapCount && mipsize > 8; ++miplevel)
mipsize /= 2;
Cubemap copy = new Cubemap(mipsize, cube.format, false);
for (int i=0; i<6; ++i)
Graphics.CopyTexture(cube, i, miplevel, copy, i, 0);
Destroy(copy);
mySky.CustomSH = null;
mySky.SH = new SHEncoding();
SHUtil.projectCube(ref mySky.SH, copy, 0, false);
mySky.SH.copyToBuffer();