- Home /
Why does this material not turn invisible?
I dragged said material under the var but nothing is working. No errors.
var material : Material;
var bool : boolean;
function Update () {
if(bool == true){
material.color.a = 0;
}
}
Are you sure you go in the "if" statement ?
$$anonymous$$aybe try "material.color = Color.clear;"
That just turned it black. I only need to make it turn invisible, but keep the color value.
Answer by robertbu · Jun 04, 2013 at 11:28 PM
The likely reason is that the shader does not support transparency. Try changing the shader for the material to something that you know supports transparency. Try Transparent/Diffuse. Beyond that make sure your import settings bring in a texture with an alpha channel...RGBA 32-bit for example.
Answer by eskontie · Jun 06, 2013 at 05:04 PM
Well this is my solution for that. This makes the object disappear(becomes invisible).
I haven't test this on materials, but it could work.
Hopefully this helps you.
var object : Object;
var bool : boolean;
function Update () {
if(bool == true){
object.renderer.enabled = false
}
}
In this case, it's like there is no game object anymore (no collision, no control ...). If he wants the game object to stay active (because it's still useful), this solution does not work.
If not, it is enough :)
Your answer
![](https://koobas.hobune.stream/wayback/20220613103533im_/https://answers.unity.com/themes/thub/images/avi.jpg)