I'm working in 2D.

I have set up 2 cameras. One for UI and another one for gameplay.

I need the UI to be rendered after before game objects (over gameplay). I wanted to achieve this without using world space canvas, because It requires being scaled for every other device along with a camera.

UI can be drawn over gameplay using greater depth than gameplay camera. And because it's depth only there is no solid color, so it all works well.

But you cannot set gameplay camera to depth only because it doesn't render things right, it doesn't clear the render texture I guess.

So this is what happens if gameplay camera is set to depth only.

Render problem image

This is what happens when gameplay camera is set to Solid Color and UI Camera has bigger depth. You can see that the ring is covered by UI arrow.

UI Arrow image cover

If the UI Camera depth would be lower than gameplay camera (Solid Color). It would all be covered by gameplay camera without even displaying UI.

These are mine settings.

Camera 1 settings imageCamera 2 settings iamgeCanvas settings image

Is there a way to achieve this in Unity without using World Space Canvas Mode?

  • \$\begingroup\$ Your screenshot is quite confusing. What of it is supposed to be the UI canvas? The red stuff or the white stuff? \$\endgroup\$
    – Philipp
    Sep 22, 2017 at 0:08
  • \$\begingroup\$ @Philipp There is no UI on that image. It shows the effects of what happens when Clear Flags are set to Depth Only on gameplay camera. White dots is a particle system that didn't clear after disappearing. Red lines are a circle gameobject that was moved around. \$\endgroup\$ Sep 22, 2017 at 0:14

2 Answers 2


This (your first screenshot) happens when you have no cameras that clear everything. All you need is a Background Camera that renders nothing (remove all render flags in the culling mask) but a Solid Color (set the clear flags to solid color). Then just set the depth of the Background Camera lower than your Main Camera. Your UI Camera should have a depth value that is higher than both cameras (if I understood what you want correctly).

I'm not sure why you want to have a setup like this, but since you do, there you go. This setup should be possible with just one camera though.

  • \$\begingroup\$ Thanks, I will try that once I have time to do that. That is pretty old question. Once I make sure I will accept the answer. \$\endgroup\$ Nov 26, 2017 at 11:02
  • 1
    \$\begingroup\$ This is a 4yo question, probably what I wanted to achieve is draw UI behind gameplay elements, but couldn't do that with screen space UI since solid color of gameplay camera rendered over the UI. I should have set both of them to not have any solid color and just use a dummy camera as you said to clear rendered things or something similar. At that time was clueless how the rendering works :) \$\endgroup\$ Jan 12, 2022 at 10:43

I've seen some of these problems in my own work though I can only comment on the red artifacts as I have never done the same thing as you have in 2D - I have made it in 3D - worked through the problems also. So here goes.

First the red game object is doing that because I think you don't have a background but using a solid black colour. If you can - try using an Unlit shader that is coloured black and try that again - this should fix the artifacts.

As for the cameras - I think you should swap your camera depths around and put put both your camera clear flags to depth only.

Let me know if that works.

  • \$\begingroup\$ You mixed it up a little. I understand why these artifacts occur more or less and I don't have any background, so switching background shouldn't change anything. They happen while Clear Flags set to Depth Only when it's set to Solid Color - it renders perfectly without any artifacts. About camera settings, I have written that I have already used depth only on both cameras at the same time and changed many settings. The solutions should be more in a direction of render texture and shaders I guess rather than playing with the settings (but maybe there is some workaround). \$\endgroup\$ Sep 22, 2017 at 16:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .