I want to highlight a certain item in an inventory. It is a 3D scene although it looks a bit 2D. That is confirmed.

To do do that I have create a cube with a very small z scale (so that it looks like a plane... yes, I could have used a plane right away, I notice it now that I write it).

I have put a transparent material onto my cube. This material constantly changes its alpha value so that it looks like it's glowing.

I'm doing this because I want to re-do this inventory:

enter image description here

It does work, but my weapon is rendered before the glowing cube is renderer. That is the default behaviour as the weapon is physically in front of the glowing cube.

In the inventory system that I want to redo (see screenshot), the cube however it rendered after the weapon, so that it looks as if the cube was over the weapon (while in fact it is below the weapon. One can see that by the fact how perfectly the glowing cube aligns with the grid, and the weapon is over the grid).

I would therefore like to ask if I can make it so that a certain material / mesh is rendered after a certain other material.

I have only seen Sorting Layers for 2D, but nothing for 3D meshes.

Thank you very much!

Edit: Somebody suggested that I should place the glowing cube over the weapon. I had tried that, but it doesn't look good as the cube isn't "aligned" with the grid anymore, but hovers / floats over it instead. Here is a screenshot:

enter image description here

  • \$\begingroup\$ "That is the default behaviour as the weapon is physically in front of the glowing cube." - if it's a 2D GUI screen, then why not put the glowing cube physically in front of the weapon? \$\endgroup\$
    – user253751
    Jun 20, 2019 at 22:43
  • \$\begingroup\$ It's a 3D scene. \$\endgroup\$
    – tmighty
    Jun 20, 2019 at 22:44
  • \$\begingroup\$ Then... shouldn't it be even easier to put the glowing cube in front of the weapon? \$\endgroup\$
    – Alex F
    Jun 20, 2019 at 22:51
  • 2
    \$\begingroup\$ Are you sure your problem is draw order and not depth testing? \$\endgroup\$
    – DMGregory
    Jun 21, 2019 at 0:59
  • 1
    \$\begingroup\$ Depth testing is what keeps an object behind a different one from drawing on top of it, even if it draws later in the frame. Before shading each pixel, the GPU checks the depth of the current surface versus the depth stored in the depth buffer at that point. If the value in the depth buffer is less, that means something drawn earlier is in front of this object, and we can skip shading this pixel because it's occluded. (There are other ways to use the depth buffer / depth testing, but this is the conventional way). So, your problem may be that you want to disable depth testing for this material \$\endgroup\$
    – DMGregory
    Jun 21, 2019 at 11:07

1 Answer 1


The Unity bug report team pointed me to the solution:

https://docs.unity3d.com/Packages/[email protected]/manual/Renderer-And-Material-Priority.html

The important thing is: It works only for "Surface Type: Transparent". If you're dealing with 2 materials which have surface type "Transparent", then you can set their render order using the "Sorting Priority".

If you have 2 materials where one has surface type "Opaque", and the other one has surface type "Transparent", then Unity will decide the render order using depth testing, and you have no way to influence the render order.

So the way to solve the mentioned problem is to set the surface type "Transparent" for all meshes involved.

  • 1
    \$\begingroup\$ To make the answer more future-proof, it would be better to post the steps you followed to find the solution, than posting a link to it. Links tent to get broken, making the question not useful for people having similar issues. \$\endgroup\$ Jul 9, 2019 at 11:15
  • \$\begingroup\$ In case he doesn't answer, it looks like he modified either the 'Sorting Priority' of the surface of his material, OR he modified the 'Priority' of his Mesh Renderer. \$\endgroup\$ Aug 8, 2019 at 22:27
  • 1
    \$\begingroup\$ @TomTsagk I have edited my answer accordingly. Thanks. \$\endgroup\$
    – tmighty
    Aug 13, 2019 at 19:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .