- Home /
Unity 5 standard shader transparency not working on mobile
I'm making a small racing game, and when the player is inside a tunnel, it's supposed to be transparent so the player is still visible.
In editor it looks like this: http://pokit.org/get/img/ca61cbf8cd9bbf76a58762b4ee990bfe.jpg
While on mobile it just slightly flashes for a moment, and returns to normal (no opacity at all, same code)
I've tried a lot, including iTween and simply changing renderer.material.color, but didn't find a solution. This is my current code using the standard shader:
To make it invisible (transparent):
Material material = this.materialCarry.GetComponent<Renderer>().material;
material.SetFloat("_Mode", 2);
material.SetFloat("_Mode", 2);
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
material.SetInt("_ZWrite", 1);
material.DisableKeyword("_ALPHATEST_ON");
material.EnableKeyword("_ALPHABLEND_ON");
material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
material.renderQueue = 3000;
material.SetColor("_Color", cColor = Color.Lerp(cColor, fadeColor, Time.deltaTime * fadeSpeed));
To make it VISIBLE (no transparency)
Material material = this.materialCarry.GetComponent<Renderer>().material;
material.SetFloat("_Mode", 2);
material.SetFloat("_Mode", 2);
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
material.SetInt("_ZWrite", 1);
material.DisableKeyword("_ALPHATEST_ON");
material.EnableKeyword("_ALPHABLEND_ON");
material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
material.renderQueue = 3000;
material.SetColor("_Color", cColor = Color.Lerp(cColor, normalColor, Time.deltaTime * fadeSpeed));
Your answer
Follow this Question
Related Questions
Transparent shader for Android 1 Answer
My Transparency Shader Is No Longer Working on Mobile? 0 Answers
mobile shader transparency issue 0 Answers
Alpha as Illumination AND Transparency? 0 Answers