Unity 3D Game Engine – Set Material Transparency

1. MAIN TOP MENU> Gameobject> Create Other> Cube

2. Hierarchy, select the Cube> Inspector> materal slot, select Shader: Transparent/Diffuse

NOTICE; YOu HAVE TO USE a Transparent shader, in Unity3D only Transparent Shaders support alpha channel

3. Select the Cube and assign SetTransparency.JS:

1
2
3
4
5
6
7
8
#pragma strict
 
    function Start () {
    }
 
    function Update () {
        gameObject.renderer.material.color.a = 0.5; // set transparency to 50%
    }