ES3.SaveImage

public static void SaveImage(Texture2D texture, string imagePath, ES3Settings settings)

Description

Saves a Texture2D as a PNG or a JPG, depending on the file extension of the supplied imagePath.

Parameters

[table th=”0″]texture,”The Texture2D we want to save as an image.”

imagePath,”The relative or absolute path of the PNG or JPG file we want to store our image to.”

settings,”[Optional] The settings we want to use to override the default settings.”[/table]

Examples

C#

// Take a screenshot.
var texture = new Texture2D(Screen.width, Screen.height);
texture.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0);
texture.Apply();
  
// Save the screenshot as a PNG file.
ES3.SaveImage(texture, "screenshot.png");

// Save the screenshot as a JPG file.
ES3.SaveImage(texture, "screenshot.jpg");

JS

// Take a screenshot.
var texture = new Texture2D(Screen.width, Screen.height);
texture.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0);
texture.Apply();
  
// Save the screenshot as a PNG file.
ES3.SaveImage(texture, "screenshot.png");

// Save the screenshot as a JPG file.
ES3.SaveImage(texture, "screenshot.jpg");