ES3.SaveImage
Description
Saves a Texture2D as a PNG or a JPG, depending on the file extension of the supplied imagePath.
Parameters
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. |
Examples
C#
1 2 3 4 5 6 7 8 9 10 |
// 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
1 2 3 4 5 6 7 8 9 10 |
// 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"); |