Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Meltdown on March 10, 2014, 09:23:28 PM

Title: How can I make a UILabel in a scene always render on top?
Post by: Meltdown on March 10, 2014, 09:23:28 PM
In our current project we are having a Windows Phone 8 specific issue where UILabel text that is supposed to be drawn in front of the enemy, is in some cases being drawn behind or in it.

See the attached image..

Is there any way to force the label to be drawn in front? And how can I change the shader for this UILabel?

Thanks
Title: Re: How can I make a UILabel in a scene always render on top?
Post by: ArenMook on March 11, 2014, 05:56:17 PM
If the label is a part of your 3D scene (drawn with the 3D camera), then it will be affected by depth. This is why the UI is typically drawn using a separate, orthographic camera.

If you want to use 3D UI elements and want them to always be on top, create a 3D UI instead of placing UI elements in your world (read: separate UI camera).
Title: Re: How can I make a UILabel in a scene always render on top?
Post by: Meltdown on March 18, 2014, 06:58:23 PM
For anybody else who wants to make sure the text is always rendered on top, you can modify the NGUI Text Shaders by adding ZTest Always to the shader.

So in the NGUI/Resources/Shaders folder, edit Unlit - Text.shader...

Under the first line that says ZWrite Off

add this line...

ZTest Always