How to make a material invisible?

I know that I can make a material for an object invisible by using:

gameObject.renderer.material.color.a = 0;

But this makes the material invisible for this object only. I use the same material on multiple objects, and I want them all to be invisible. How would I do that?

To clarify: I have a character with multiple parts, some of which are weapons that are made visible via ‘renderer.enabled’ separately, one at a time. If the player’s health reaches 0, I want him to become invisible for a short amount of time (to make him explode via particles and rebuild him after some time). I use the same material for all parts of the character, and for nothing else, so I thought it would be the most practical way to make him invisible.

Use renderer.sharedMaterial.

In the Object theres the Mesh Renderer, and if you disable it the object will be invisible but still in the scene. But if you want to set this on the material, the n the material has to transparent.

  1. Open power point if you have it
  2. Make a square - any other shape
  3. Set the outline to no colour
  4. And save that as a picture.
  5. In Unity put the texture onto to the object
  6. Set to Transparent>Diffuse instead of Diffuse
  • Felipe