[Shader] Draw World Space UI Always On Top

If you want to draw UI in VR (for example Google Cardboard), it doesn’t support ScreenSpace rendermode in canvas..
So all the UI’s are using WorldSpace RenderMode.. which causes issues when UI goes behind geometry.

Fix: You can modify UI shader to disable ZTest

Shader source: (tested with 5.6.0b3)

*Only one line was modified from original UI shader,
// From
ZTest [unity_GUIZTestMode]

// To
ZTest Off

2 Comments + Add Comment

  • Just when I need it ! Thank you 🙂

    I’ve put it on all “Image” and “Text” components of my UI. Is there a way to replace the default UI shader by this one ?

    • Yes, i believe if you rename the shader as: Shader “UI/Default”
      then it might override the built-in one..

Leave a comment


Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.