# LineRenderer sorting order - lines always in front of everything

I have 3 cameras and 3 canvases.

1. Back Camera: depth = -5, Back Canvas: Sorting layer - BackLayer,
2. Camera: depth = 0, Middle Canvas: Sorting layer - MiddleLayer,
3. Camera: depth = 10, Front Canvas: Sorting layer - FrontLayer,

Orders in canvases are also set (for SpriteRenderers, images, ui etc.)

Back is for a background image and stars, middle for mountains and front for the UI. Everything is working perfectly with one exception:

No matter where I draw lines with a LineRenderer - they're always at the front of everything (each canvas).

The one situation where the line moves deeper is when I set it's points Z to some huge values like 30000 and then - they're just behind everything.

My goal is to place these lines along with the background image and stars on the BackLayer or BackCanvas.

• Setting LineRenderer sorting layer and it's order from the code. I read somewhere on Unity forums that lineRenderer has to have a special material for this to work but I tried most of them - not working.

• I also tried setting their positions manually, from the inspector, from the code, incrementally in the Update() method - they're always in front or complately hidden (with huge numbers mentioned above).

• I tried assigning them to different canvases (back, middle, front) as children didn't work too.

On Unity forums I also read a post which says that we shouldn't use sorting layers with linerenderer and use only Z positions.

If someone has any experience with this, I would be grateful. I really have no idea if I'm doing something wrong or what.

First of all - SpriteRenderer and LineRenderer don't cooperate, as they say on Unity forums.
There are two ways of changing the LineRenderer's draw order:
• By changing the position in the line's material's Render Queue to lower: