Maybe I’m missing something simple, but I can’t get images to change display order. For example some of my images overlap other elements they shouldn’t. I would think this would be fixed through RectTransform position z, but it doesn’t seem to do anything. Also unlike the sprite renderer, there is no option to set it to a sorting layer. Any tips on how to fix this?
Elements on a canvas are rendered by order in the hierarchy, from top to bottom. Simply rearrange the items in the hierarchy to get the desired effect.
There are also a couple of new methods available to let you set the position in the hierarchy via code.
Canvas component also has the sortingLayerName variable which allows you to order it below some sprites and above others if so desired:
I’d been vainly hunting in the Canvas Renderer for this, widened my search thanks to Stardog’s comment on the other answer.
Similarly sortingLayerID and sortingOrder can be set in this way.
edit: set Canvas render mode to something other than “Screen Space - Overlay” and you can see the sorting layer in the Inspector (don’t know if this is new, I’d never noticed it before). It seems the Overlay view doesn’t work with sprite sorting layers but the other modes do.
Particles will be foreground to other UI element’s if you do the following steps:
(Also you need to make Canvas mode to “ScreenSpace”)
This image show’s how to make parcticles system be foreground to UI.
But with just UI element’s logic is the same – just set sorting layer to correct for exact element.
Apparently someone (Teku Studios) figured out how to expose Sorting Layer and Order for ALL mesh renderers, not just UI elements. This really helps when mixing UI and non-UI elements: