Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void SaveRenderTexture(RenderTexture rd)
- {
- Texture2D screenShot = new Texture2D(rd.width, rd.height, TextureFormat.RGB24, false);
- RenderTexture.active = rd;
- screenShot.ReadPixels(new Rect(0, 0, rd.width, rd.height), 0, 0);
- RenderTexture.active = null;
- byte[] bytes;
- bytes = screenShot.EncodeToJPG();
- string nameOfTheImage = rd.name + ".jpg";
- // use Path.Combine for platform independet / or \
- string pathToTheFile = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) +
- "/" + UnityEngine.SceneManagement.SceneManager.GetActiveScene().name + "/" + "set01" + "/";
- if (!Directory.Exists(pathToTheFile))
- {
- Directory.CreateDirectory(pathToTheFile);
- }
- string fileName = pathToTheFile + nameOfTheImage;
- System.IO.File.WriteAllBytes(fileName, bytes);
- }
Add Comment
Please, Sign In to add comment