I have the same problem, and have looked at articles/posts everywhere trying to figure out. I cannot figure out the solution either.
It may be:
1. Render Queue problem?
2. A shader problem?
3. Something needs to be adjusted in the settings?
** I don’t think its a bug, then I’ve been seeing posts about this all the way back to 2015.
** Code seems to work fine, because it works okay inside unity…just not on build.
Attached is the Video and Code of what is happening
0yvst
// Update rendering mode
if (visible)
{
// Opaque
material.SetFloat("_Mode", 0f);
material.SetInt("_ZWrite", 1);
material.EnableKeyword("_ALPHATEST_ON");
material.DisableKeyword("_ALPHABLEND_ON");
material.EnableKeyword("_ALPHAPREMULTIPLY_ON");
}
else
{
// Transparent
material.SetFloat("_Mode", 3f);
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
material.SetInt("_ZWrite", 0);
material.DisableKeyword("_ALPHATEST_ON");
material.EnableKeyword("_ALPHABLEND_ON");
material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
material.renderQueue = 3000;
}
// Update color
if (material.HasProperty("_Color"))
{
var color = material.color;
color.a = (visible ? 1f : 0.2f);
material.color = color;
}