public static string SaveScreenShotWithBorder(Rect r, Color borderColor, string name)
{
int width = (int) r.width;
int height = (int) r.height;
Color[] colorArray = InternalEditorUtility.ReadScreenPixel(new Vector2(r.x, r.y), width, height);
Color[] pixels = new Color[(width + 2) * (height + 2)];
for (int i = 0; i < width; i++)
{
for (int m = 0; m < height; m++)
{
pixels[(i + 1) + ((width + 2) * (m + 1))] = colorArray[i + (width * m)];
}
}
for (int j = 0; j < (width + 2); j++)
{
pixels[j] = borderColor;
pixels[j + ((width + 2) * (height + 1))] = borderColor;
}
for (int k = 0; k < (height + 2); k++)
{
pixels[k * (width + 2)] = borderColor;
pixels[(k * (width + 2)) + (width + 1)] = borderColor;
}
return SaveScreenShot((int) (r.width + 2f), (int) (r.height + 2f), pixels, name);
}