2 using System.Collections;
9 Debug.Log (
"'SaveRenderTexture' active. Press T to save the UI render texture.");
14 if (Input.GetKeyDown(KeyCode.T))
21 Camera cam = GameObject.Find (
"UICamera").GetComponent<Camera> ();
22 RenderTexture renderTex = cam.targetTexture;
23 RenderTexture.active = renderTex;
24 Texture2D tex =
new Texture2D (renderTex.width, renderTex.height, TextureFormat.ARGB32,
false);
25 tex.ReadPixels (
new Rect (0, 0, renderTex.width, renderTex.height), 0, 0);
27 RenderTexture.active = null;
29 byte[] data = tex.EncodeToPNG ();
30 File.WriteAllBytes(
"renderTexture.png", data);
31 Debug.Log (
"Saved texture to: 'renderTexture.png'");