private static SaveScreenShot ( int width, int height, Color pixels, string name ) : string | ||
width | int | |
height | int | |
pixels | Color | |
name | string | |
return | string |
private static string SaveScreenShot(int width, int height, Color[] pixels, string name)
{
Texture2D textured = new Texture2D(width, height);
textured.SetPixels(pixels, 0);
textured.Apply(true);
byte[] bytes = textured.EncodeToPNG();
Object.DestroyImmediate(textured, true);
string uniquePathForName = GetUniquePathForName(name);
File.WriteAllBytes(uniquePathForName, bytes);
Debug.Log(string.Format("Saved screenshot at {0}", uniquePathForName));
return uniquePathForName;
}
ScreenShots::SaveScreenShot ( |
public static string SaveScreenShotWithBorder(Rect r, Color borderColor, string name) { int num = (int)r.width; int num2 = (int)r.height; Color[] array = InternalEditorUtility.ReadScreenPixel(new Vector2(r.x, r.y), num, num2); Color[] array2 = new Color[(num + 2) * (num2 + 2)]; for (int i = 0; i < num; i++) { for (int j = 0; j < num2; j++) { array2[i + 1 + (num + 2) * (j + 1)] = array[i + num * j]; } } for (int k = 0; k < num + 2; k++) { array2[k] = borderColor; array2[k + (num + 2) * (num2 + 1)] = borderColor; } for (int l = 0; l < num2 + 2; l++) { array2[l * (num + 2)] = borderColor; array2[l * (num + 2) + (num + 1)] = borderColor; } return(ScreenShots.SaveScreenShot((int)(r.width + 2f), (int)(r.height + 2f), array2, name)); }