How To Fix Unity3d Transparent Shader Not Respecting Z-Index

Before and After: Unity3d Transparent Shaders Respecting Z-Index
Before and after. Bright colours used to demonstrate effect of fix.

The fact that, by default, the transparent shaders in Unity3d do not work well behind or in front of objects has been a problem for years. Here’s an easy fix that might solve it for you.

Steps

  1. Make a duplicate of the transparent shader in question. For me, this was Unlit – Transparent Tint. I found it by searching my Project window in the Unity3d editor for “Unlit”.
  2. Edit the new shader in a text editor (default: MonoDevelop).
  3. On line 1, change the name of your shader to something you’ll remember. This is where it will be in your shader selection dropdown in the editor.
  4. Under the SubShader section, add +1 to the item in the “Queue” section. For me, this became “Queue” = “Transparent+1”.
  5. Save your shader.
  6. Apply it to your game object.

That’s it! With any luck, the object with your transparent shader should now appear in front of other game objects which also use a transparent shader.