Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public class SaveRenderTexture : MonoBehaviour {
- public RenderTexture texture;
- [ContextMenu("Save")]
- private void Save() {
- var currentActiveRT = RenderTexture.active;
- RenderTexture.active = texture;
- var screen = new Texture2D(this.texture.width, this.texture.height, TextureFormat.ARGB32, false);
- screen.ReadPixels(new Rect(0, 0, this.texture.width, this.texture.height), 0, 0);
- var bytes = screen.EncodeToPNG();
- System.IO.File.WriteAllBytes(Application.dataPath + "/Temp/screen.png", bytes);
- RenderTexture.active = currentActiveRT;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement