Steps to reproduce:
- Create a screen space (camera) canvas and fill it with lots of UI elements. Make sure it’s set to render via the main camera.
- Create a second camera, disable it, and set its culling mask to ‘None’
- Add a script that has an OnRenderObject method which calls ‘Render()’ on the disabled camera.
- Profile the scene.
You’ll see something like this:
UGUI will go to all the trouble of culling and batching the entire contents of the UI, even though the canvas is explicitly targeted at a different camera and is in a layer excluded from the second camera’s mask.
We are using a number of cameras to render elements of our UI on demand, and this bug is killing us. Every camera we render triggers a complete rebatching of the entire UI, even though none of it will ever be drawn through that camera.