RenderTexture not showing UI elements
I want to take a screentshot from UI elements inside a canvas in screen space-overlay render mode. So I added a renderTexture to the main camera. If I change the render mode to World Space then UI elements show up. What is happening and why the UI layer is not being rendered by camera in space-overlay?
Answer by wenderRondonia · Feb 28, 2017 at 02:57 PM
Found the issue: https://issuetracker.unity3d.com/issues/rendertextures-do-not-include-canvas-ui-elements It is intended to do that by design. To solve this you have to call Render before taking the screenshot so UI is forced draw.
Camera.main.renderTexture = myRenderTexture;
Camera.main.Render();
Caemra.main.renderTexture = null;
so it forces to render the UI layer.
There is not .renderTexture member. Did you mean targetTexture? In any case I added this code to my main camera in the Update() it the UI does not render in ScreenSpace-Overly mode.... It only renders in ScreenSpace-Camera mode, even without this code by attaching the renderTexture to the camera using there targetTexture slot.
Are you sure it worked for ScreensSpace-Overlay?
Answer by maryamhatami1375 · Sep 14, 2019 at 11:26 AM
Yes I have this problem too. In screen space overlay camera can not show ui elements dynamically neither statically. I'm still searching for a solution.
render texture is designed render the elements that has depth, so screen space overlay elements does not write in the depth buffer unlike world space and screens pace - camera.
Your answer
Follow this Question
Related Questions
Capturing high resolution screenshot with Temporal AA 1 Answer
Capture Screenshot on Linux Headless Machine 3 Answers
Using 3D Render Texture with camera 0 Answers
CommandBuffer draw renderer to render texture in specific place and with light 0 Answers
Issue with using render texture and custom projection matrix 0 Answers