- Home /
Question by
Cooper_Davies · Apr 20, 2020 at 08:55 AM ·
camerarenderingcanvas
Camera rendering with canvas overlay shrinking
I'm trying to render my Camera to a texture2D with a scree space - camera overlay. When I render the camera in game view I get the correct output but when I render to a separate target texture, the canvas shrinks.
In the above image the left is what is being rendered to the texture while the right is what the camera renders in the game window.
The code I have for rendering to a separate texture is:
cam.targetTexture = new RenderTexture(width, height, 24);
RenderTexture.active = cam.targetTexture;
cam.Render();
Texture2D imageOverview = new Texture2D(width, height, TextureFormat.RGB24, false);
imageOverview.ReadPixels(new Rect(0, 0, width, height), 0, 0);
imageOverview.Apply();
Does anyone know why this isn't working, and how I fix it? I have the canvas set to scale with screen size with pixel perfect toggled on if that helps at all.
example.png
(335.0 kB)
Comment