I have one object with two materials. i want to change the texture of one of the specific materials programatically. Can i do this and if so how?
This is one way to do it, you will have to know the name of the material and name of the texture property.
Material foundMaterial = null;
foreach(Material mat in renderer.materials)
{
if(mat.name == "my-material")
{
foundMaterial = mat;
}
}
if(foundMaterial)
{
foundMaterial.SetTexture("propertyName", myTexture);
}
To find the property name of your texture, look at your shader script. Check highlighted.
[30990-screen+shot+2014-08-15+at+10.54.53+am.png|30990]