Saving and Loading Images

You can use Easy Save to to load a JPEG or PNG image as a Texture2D. You can also save a Texture2D as a PNG.

You can load a JPEG or PNG file as a Texture2D using ES2.LoadImage.

For example, to load a JPG from a user’s hard drive into a GameObject’s material, you could use the following code:

renderer.material.mainTexture = ES2.LoadImage("C:/Users/User/myImage.jpg");

To save a Texture2D as a PNG, you use the ES2.SaveImage method.

For example, to save the Texture2D assigned to a GameObject’s material, you could use the following code:

ES2.SaveImage(renderer.material.mainTexture, "C:/Users/User/MyImage.png");