In this recipe, we will create an object that, once clicked, fades out and disappears. However, the script will be flexible enough to allow us adjust the initial and final alpha values. Plus, we will have the option of making the object self-destructible when turned invisible.
Follow these steps:
Add a Sphere to your scene by accessing the GameObject | 3D Object | Sphere menu.
Select the Sphere and make sure it has a collider (if you are using a custom 3D object, you might have to add a collider through the Components | Physics menu).
Create a new material. The easiest way to do that is to access the Project view, click the Create drop-down menu, and choose Material.
Rename your new material. For this example, let's call it
Fade_MAT
.Select your material. From the Inspector view, use the drop-down menu to change its Rendering Mode to Fade: