[Unity]Making an object translucent with a script
This time I would like to make an object translucent with a script.
First, I place a slightly larger cube and then a smaller cube behind it.
The larger cube has a red material attached to it.
In the current state, only the red cube is visible, but there is a white cube behind it.
Next, set the red cube’s material shader to Legacy Shaders → Transparent → Diffuse.
Next, create a new script for the red cube and write the following.
Since this is a sample, it is written in Start, but the value of color.a is set to 0.6f to make it semi-transparent.
Setting it to 1.0f makes it completely transparent.
When the game is executed, the red cube becomes translucent and the cube behind it becomes visible.