Canvas render-to-texture problems

Hi, I’m trying to render a Canvas (amongst other things) to texture, as part of a blur effect. And it’s looking like canvases don’t render to texture properly? (Only tested in the editor so far)

My code is using Camera.Render() - after copying the real camera’s setup to a temporary camera. And this doesn’t seem to be rendering any canvas content at all.

Then as a test, I tried assigning a RenderTexture asset to ‘Target Texture’ on one of my UI cameras - and doing it that way, it’s picking up something on the RenderTexture, but it’s only a small area of the UI (the RenderTexture was smaller than the screen resolution)

(This code all worked previously with NGUI - and still works to capture+blur 3D content. It’s only canvases that it’s having problems with. My canvases are set up as Screen Space - Camera, so it’s not a case of overlay layers not being rendered to texture)

Has anyone else tried rendering a canvas to texture?

(Currently running 4.6.0f3)

Yes multiple others have tried this. Is a bug in the current version that has been fixed for a upcoming release. Its mainly a issue with Camera.Render not informing the canvas that its rendering. If you use Application.CapturesScreenShot or wait till end of frame it should work but likely not what you’re hoping for.

@phil-Unity
This issue still exists in unity 5.6 and 2017 versions. In editor it works as expected but as soon as doing a build for device it doesn’t.
This is easy to reproduce:

  • Have a canvas set up with a few elements and base it on a 4:3 aspect ratio.
  • Set up an ortho camera for rendering the UI and set canvas to “screen space - camera” mode
  • Add a render texture 1024*768 to the project and link it to the camera
  • Run on a device thats not 4:3 aspect ratio, you will notice that the scaling on elements is all weird.

Disabling the canvas scaler component fixes it, but the question is why doesn’t it work with it enabled?

1 Like