Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Can't get mesh renderer sorting layer to work in Unity

Hi so I am making a game for a uni project and I started off using shapes instead of sprites and I don't have enough time to change it all to sprites now. I have some sprites that I need to render in front of the shapes. I found this script online which says that it exposes the sorting layer in the mesh renderer component in the inspector: https://gist.github.com/sinbad/bd0c49bc462289fa1a018ffd70d806e3 . I tried it and it works, I can edit the sorting layers for the mesh renderer in the inspector... but it doesn't seem to be making any difference to the sprite rendering in front or behind the shape in my scene. What am I missing? Does this work? What can I do to make the sprite render in front?


Best Answer

  • MouledouxMouledoux Member
    edited June 29 Accepted Answer

    Set whatever you want to be in front to a higher 'Order in Layer'

    Also, you could already do sorting orders like that, so I'm not sure what you downloaded.


    Edit: Never mind, instead, make a 2nd camera, have it only render 1 layer, the layer with your always in front stuff in it, and set that camera's 'Depth' to something like 2

Answers

  • @Mouledoux but shouldn't "symbols" always render in front of "background" because it is further down the list? I thought when you added a new sorting layer it will be the front layer. Is this not correct?

  • For 2d stuff yea, but you said you had 2d, and 3d elements.

  • @Mouledoux great thanks that works, never thought of that!

Sign In or Register to comment.