Hi,
You can prevent this, here’s what I would do:
Spawn a large quad (single cell plane) with a TextMeshPro text on it, place it like 10m in fron of cam in world space and, child the quad to nothing, child the TextMeshPro to the quad.
Now if you used standard materials then you will see any of your game geometry occlude this sign you’ve made. And if you do not have determinism over where your player may be this is a problem, the sign may never be seen if they are facing a wall etc.
But… if you disable ztest and zwrite on the quad and mesh material and give them a high render queue priority they will be drawn over everything, regardless of Zpos relative to cam.
To disable ztest/zwrite you need a shader setup for that.
Here is a simple color shader for your quad:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ____ ___ _ ___ ____ ___ _ _ ____ ____ ___ ___ ____
// / ___|_ _| | |_ _/ ___/ _ \| \ | | | _ \| _ \ / _ \_ _| _ \
// \___ \| || | | | | | | | | \| | | | | | |_) | | | | || | | |
// ___) | || |___ | | |__| |_| | |\ | | |_| | _ <| |_| | || |_| |
// |____/___|_____|___\____\___/|_| \_| |____/|_| \_\\___/___|____/
//
// MOBILE: UNLIT COLOR WITH ALPHA
//
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Shader "SiliconDroid/Mobile_UnlitAlphaTextureNoZ"
{
Properties
{
_Alpha ("Alpha", Range (0.0,1.0)) = 1.0
_MainTex ("Base (RGB) Transparency (A)", 2D) = "" { }
}
Category
{
Lighting Off
ZWrite Off
ZTest Off
Cull back
Blend SrcAlpha OneMinusSrcAlpha
Tags {Queue=Transparent}
SubShader
{
Pass
{
SetTexture [_MainTex]
{
constantColor (1, 1, 1, [_Alpha])
combine texture * constant
}
}
}
}
}
For the TextMeshPro, you can select one of it’s bundled shaders to do the same, you might also use that shader instead of the one I supplied above for your quad.
I recommend: spawn your big sign with both it materials at zero alpha and use a script to ramp the alpha to 1 over some time, this will have the result of fading your scene to this sign.
Use this function to change your alphas in script:
// modulate float fAlpha using coroutine etc.
oMyMaterial.SetFloat("_Alpha", fAlpha);