- Home /
Set unity_GUIZTestMode in UI Shaders?
I'm using uGUI, and I have a few canvases in world-space, spread throughout a scene, that I want to render on top of everything else.
Rendering these canvases on top is fairly simple: download the built-in shader source code for 5.0, grab (say) the UI/Default Font shader, make a copy, and set the Queue to Overlay and the ZTest to Always.
However, when I opened up the shader, I noticed that the ZTest is set as:
ZTest [unity_GUIZTestMode]
This seems eminently useful! It seems like if you could set this value, you could:
Create a material that uses the UI/Default Font
Apply this material to all elements on a given UI
Set the unity_GUIZTestMode for this sharedMaterial
That way, I'm not modifying the built-in shaders, and when the next version of Unity comes out I don't have to check all my hacked shaders and update them to match whatever changes Unity has made to the default shader.
Here's the issue:
I've never seen this particular shader setup before. I know how to do, say, material.SetFloat. But there is no 'set string' or 'set enum' or similar. I'm pretty sure this isn't a shader keyword (those are set in the #pragma statements). I've looked through the source with ILSpy and searched on Google, and I can't figure out where this value is being set.
So how the heck can you set the unity_GUIZTestMode in a material from script? Is there a way to do it? Or do I just have to make a copy of all the shaders and do it the hacky way?