Trailrenderer sorting in canvas

Hi! I have a 2D scene with a screen space camera canvas. I also draw into the scene with trail renderers. The problem is that I’m unable to sort the trail renderers with sorting layers. Every canvas object set to a specific sorting layer draws in the correct order but the trail renderers simply draw over everything.

Setting the renderers to the backmost sorting layer like this has no effect.

void Start () 
{
    TrailRenderer trail = GetComponent<TrailRenderer>();
    trail.sortingLayerName = "background";
    trail.sortingOrder = 0;
}

It is not clear to me where you have this script attached… so I might put a test to see if you have actually assigned a TrailRenderer to the variable “trail” to confirm that you are actually accessing the renderers.