Hey folks !
I added a 3D Text object (from GameObject menue) to my scene but the mesh is always displayed on top.
Is there a way to turn that off? Or is there something comparable that I could create to get a 3D Text that is not visible when it’s behind another mesh?
You can have your 3D text use a material with a standard alpha shader (like Alpha/Vertexlit) instead of the font shader. However I think you need an actual bitmapped font texture rather than the one that Unity generates from a .ttf file. (Or at least that’s what works here.) There’s a template for creating bitmapped fonts on the wiki.
–Eric
You don’t need a special font texture. You should be able to just make a material with an alpha shader and the font texture generated by the ttf file.
My mistake; the font didn’t match up with the font texture when I first tried that. However now I’m getting another problem: with an alpha shader the generated bitmapped font only shows up from the back, but a normal bitmapped font shows up from the front. (A 2-sided shader would fix that problem, of course.) If I change the font to “none” instead of Courier, it “shows up” from the front, except it’s invisible. 
In the pics, that’s default on the top, generated bitmapped font texture + alpha shader in the middle, normal bitmapped texture + alpha shader on the bottom. I’m still probably doing something wrong, but I can’t figure out what.
–Eric


I think for text you really want to make a special shaders that renders double sided without lighting and that does no backface culling.
Something like my unlit vegetation shader maybe?
Shader "Vegetation" {
Properties {
_Color ("Main Color", Color) = (.5, .5, .5, .5)
_MainTex ("Base (RGB) Alpha (A)", 2D) = "white" {}
_Cutoff ("Base Alpha cutoff", Range (0,.9)) = .5
}
SubShader {
Colormask RGB
// Render both front and back facing polygons.
Cull Off
// first pass:
// render any pixels that are more than [_Cutoff] opaque
Pass {
AlphaTest Greater [_Cutoff]
SetTexture [_MainTex] {
combine texture, texture
}
}
// Second pass:
// render in the semitransparent details.
Pass {
// Dont write to the depth buffer
ZWrite off
// Don't write pixels we have already written.
ZTest Less
// Only render pixels less or equal to the value
AlphaTest LEqual [_Cutoff]
// Set up alpha blending
Blend SrcAlpha OneMinusSrcAlpha
SetTexture [_MainTex] {
combine texture, texture
}
}
}
}
Any news on that?
I also expect my 3d text to behave just as a common 3d-object with correct z-culling.
(I tried to edit the Unityshader (Font.shader from builtinshaders.zip)
to:
line10: Lighting Off Cull On ZTest Always ZWrite On Fog { Mode Off }
line229: Lighting Off Cull On ZTest Always ZWrite On Fog { Mode Off }
but I get an syntax error on line 10.
Maybe because the Textmesh has no tangents…?
I am not an expert on this.)
This script fixes it, but it should work by default.