[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.




![[Unity] Removing grass grown on Terrain from scripts](https://kuroko-labo.com/wp/wp-content/uploads/2025/05/grass2.png)
![[Unity] Executing a method at an arbitrary time with Photon’s PUN2](https://kuroko-labo.com/wp/wp-content/themes/kuroko3/images/noimage.png)
![[Unity]I made a field with Gaia Pro 2023.](https://kuroko-labo.com/wp/wp-content/uploads/2025/01/image06.png)
![[Unity]I bought an OLD TV Filter.](https://kuroko-labo.com/wp/wp-content/uploads/2019/11/image05.png)
![[Unity]Try to create a circle gauge that advances when the mouse is clicked.](https://kuroko-labo.com/wp/wp-content/uploads/2019/07/circle.fw_.png)
![[Unity]Use localPosition to create a conveyor belt-like](https://kuroko-labo.com/wp/wp-content/uploads/2019/06/image01-1.png)