- Home /
How do change the material on ONE object, not all of them?
My script changes the material variable invisible, but for all materials, not just the ones on that object. Help?
var material : Material;
var bool : boolean;
function Start(){
material.shader = Shader.Find( "Diffuse" );
material.color.a = 0;
}
function Update () {
if(bool == true){
material.shader = Shader.Find( "Transparent/Diffuse" );
}
else if(bool == false){
material.shader = Shader.Find( "Diffuse" );
}
}
Comment
Answer by Owen-Reynolds · Jun 05, 2013 at 07:42 PM
Aim at the material through a specific object. Ex: renderer.material.shader=...
That seems like the same thing as material=
but Unity automatically converts shared mats into (non-shared) unique copies when you touch them that way. It's a standard "smart pointer" trick.