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.

Using Unity3d 4.x In a Team

I’m working in a team for the 2015 NASA Space Apps Challenge and this year, like last year, we’ve run into a billion and a half problems working with Unity3d and git with more than one person. After some searching I found an awesome website that included a gitignore file that seems to do the trick. I’m not trying to rip them off, but I’m incuding the gitignore file here for my own future sanity (and just in case their site goes down).

# =============== #
# Unity generated #
# =============== #
Temp/
Library/
# ===================================== #
# Visual Studio / MonoDevelop generated #
# ===================================== #
ExportedObj/
obj/
*.svd
*.userprefs
/*.csproj
*.pidb
*.suo
/*.sln
*.user
*.unityproj
*.booproj
# ============ #
# OS generated #
# ============ #
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

Disable Oculus Rift Health Warning (Windows)

Oculus Rift Health Warning

I understand the need for a warning when loading an app for the first time off of the Oculus Share store, etc. but as a developer it’s insanely annoying to have to go through this thing every single time you run your game. So, if you’re working on an Oculus Rift app and you want to get rid of it while you work on it, here’s how to do it in Windows.

1. Create a text file called “oculus3d.reg” with these contents and run it.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Oculus VR, LLC\LibOVR]
"HSWToggleEnabled"="1"

2. Open the Oculus VR Config Tool and click on the “Advanced” button underneath the player height field.

3. Check the box confirming you don’t want to see the warning any more.

4. Develop your game faster by being able to save 10 seconds every time you test your game.