- Home /
Question by
mustang4484 · Mar 12, 2020 at 03:09 PM ·
camerarendertexturescreenshot
Problem with screenshot on render texture
Hi guys
I've a problem for to make a screenshot from my camera to render texture. I've try this script, but when start the OnPostRender my render texture always is black, and the public rendertexture change to "Temp Buffer 199 1920x1080".
Any suggestion?
Thank you
public Camera Cam;
public RenderTexture currentRT; public bool vero;
private void OnPostRender()
{
if(vero)
{
//Camera Cam = GetComponent<Camera>();
currentRT = RenderTexture.active;
RenderTexture.active = Cam.targetTexture;
Cam.Render();
Texture2D Image = new Texture2D(200, 200, TextureFormat.RGB24, false);
Image.ReadPixels(new Rect(0, 0, 200, 200), 0, 0, false);
Image.Apply();
RenderTexture.active = currentRT;
//var Bytes = Image.EncodeToPNG();
//Destroy(Image);
}
}
Comment
Your answer
Follow this Question
Related Questions
Rendering screenshot using multiple cameras and one rendertexture 0 Answers
Taking huge screenshots using camera array? 3 Answers
Taking screenshot from a second camera 0 Answers
Wierd Screen Shot Problem, texture of screen shot looks different in editor and in system. 1 Answer
Render Single Camera to Two Displays 0 Answers