- Home /
Render a game with ui to a render texture
Hello, I have been struggling with this problem and I can't get it fully work. I have used this method in order to render the actual scene to pixels. How can I render also the ui in the render texture?
Answer by Geometrical · Dec 21, 2016 at 11:21 PM
I think by following these steps you'll be able to solve the problem:
Select the Canvas you're using to render the UI and have a look at the RenderMode property. Change it from Screen Space - Overlay to Screen Space - Camera.
All the properties should not be changed except for the PixelPerfect property. Tick the Pixel Perfect textbox as it's appropriate for your case and just assign the Camera that you're using to render the Plane.
This should fix the problem, cheers.
Yeah I tried it, but all it does is that the canvas is just between the orthographic camera (I tweaked the plane distance of the canvas component also) and the plane where the rendertexture is applied. So it is no pixel effect applied to the canvas, because the orthographic camera is not supposed to draw what is infront of it to pixelated output. Ins$$anonymous$$d, the actual RenderTexture that has been dropped at the main camera's renderTexture fieldproperty outputs the mainCamera's Input. Here is the draw order:
Scene -> $$anonymous$$ainCam(RenderTexture) -> Plane(RenderTexture$$anonymous$$at) -> OrthoCam == GameView
Your approach:
Scene -> $$anonymous$$ainCam(RenderTexture) -> Plane(RenderTexture$$anonymous$$at) -> Canvas -> OrthoCam == GameView
If I try to render the canvas to the mainCam it is now pixelated, but also looks very squeezed that all ui elements are overlapping eachother and also the canvas clips a little bit, to match the canvas position to the moving $$anonymous$$ainCam. However, this problem does not appear at the orthoCam, because the orthoCam is not translating.
Your answer
![](https://koobas.hobune.stream/wayback/20220612103216im_/https://answers.unity.com/themes/thub/images/avi.jpg)