FrakyDale
FrakyDale

Reputation: 727

Transparent rendering mode doesn't work in windows build

Unity: 5.1.1f1

Lang: C#

I'm trying to set a GameObject to transparent rendering mode, ingame. It works perfectly in the editor mode, but does nothing in the windows build.

This is what i'm doing:

// make object semitransparent
Material m = transform.parent.GetComponent<Renderer>().material;
        Color color = m.color;
        color.a = 0.5f;

        m.SetFloat("_Mode", 3f);
        m.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
        m.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
        m.EnableKeyword("_ALPHABLEND_ON");
        m.renderQueue = 3000;
        m.SetColor("_Color", color);

¿Why doesn't work in Windows Build?

Upvotes: 0

Views: 2474

Answers (1)

KermEd
KermEd

Reputation: 76

Not all of the platforms are one-to-one, and the Alpha of the material you created is a reference to the root objects material and using its specific shader. Check what Shader you have applied to the material to find out why alpha isn't working.

I also would make sure that the shader is included in your built project by using Edit > Project Settings > Graphic Settings (Unity 5). In here make sure the Always Included Shaders includes the shader you assigned to the material.

As an FYI : For mobile, I've done some latency testing and find that Legacy > Transparent > Diffuse is still more reliable and faster on mobile than Standard with a Transparent Rendering Mode. But your mileage may vary.

Upvotes: 1

Related Questions