2D GameObjects rendered front of canvas images 4.6

Hello

Is it possible to have game objects appear in front of canvas images in a 2D setup?

I’ve tried sorting layers, changing the z value etc but to no avail. The canvas is always rendered on top of everything.

Thanks.

If you dont want to use 2 cameras, what you can do is, change the Render Mode of the canvas component to “Sceen Space - Camera”.

Then attach your camera to it and add a sorting layer to it, say “BackgroundLayer”.

In my 2D setup I have 3 sorting layers namely, BackgroundLayer,MiddeLayer, ForegroundLayer. Then all you have to do is add the gameobjects in the Foreground layer. I think this is what you want if I am not mistaken .
:slight_smile:

DigZou’s method is good!!

But a bit unclear to understand.

Just to help the guys that had trouble understanding what he meant. Here’s some more breakdown. Hopefully this clears things up for newbs like myself.

  1. In Unity, the top right corner there’s 3 drop down boxes. (Account | Layers | Layout)

  2. Open drop down “Layers” box

  3. You’ll see the Sorting Layer. Press “EDIT Layers…”

  4. Under sorting layers you can create your own layers by pressing “+” and dragging up and down that list

  5. The very TOP item in the SORTING LAYER list, is the farthest layer from the camera. So usually “default” is the farthest layer from the camera. Any layers after “Default” will be rendered in front.

[Example Sorting Layer]

Default <— Camera sees this last. Put your UI here

Layer 2 ← Camera sees this first. Put your art objects that you want IN FRONT of the UI

>>Camera is here<<

TO NOTE: SOrting Layer and order in Layer only appear in Sprite and Particle renderers. BUT they do exist in 3d meshes, just need a code monkey to make it visible. (Or just use z space)

are you change the camera depth ? you should use 2 camera !
one for objects and one for canvas ! the camera with higher depth is in front of other camera
and dont forgot use custom culling mask for cameras :slight_smile: