I'm using a canvas with screen space - camera because I needed a line renderer that could work for my UI.
However, I need that line to render behind Image elements on my canvas and I'm not seeing any way to accomplish that.
Every UI element on my canvas behaves like its z:90 and "order in layer": 0
but those aren't really configurable values for a UI object. My line renderer, if z:90, must have a layer order > 0, or a z
value < 90. In both cases, it shows on top of my UI.
I essentially have a canvas with a background image, which must be behind everything else, a line renderer (used to connect "dots"), and circle-shaped Images which must be on top.
Here's my hierarchy:
Canvas
|- Background (Panel, no image, color)
|- GameBoard
|- LineRenderer (Layer: default, order: 0)
|- Circle Clone(1)
|- Circle Clone(2)
|- etc...
What's bizarre is that if I turned off (active=false) the Background object, and my LineRenderer is z:90, order: 0, it works fine. It appears behind my UI elements correctly. Yet if this object is active, my LineRenderer appears on top of of the elements, despite no z/order changes.
Answer
Instead of changing Z-position you can solve this problem by Using Rendering Order
You can determine in which order your objects are drawn using the Queue tag. A Shader decides which render queue its objects belong to, this way any Transparent shaders make sure they are drawn after all opaque objects and so on.
assign Sprites shader to your line renderer's material because It have Important tag as ZWrite.
Controls whether pixels from this object are written to the depth buffer (default is On). If you’re drawng solid objects, leave this on. If you’re drawing semitransparent effects, switch to ZWrite Off. For more details read below.
so if you have custom shader use Zwrite Off
then set your own Rendering Order like this:
No comments:
Post a Comment