set a material to a object Unity code example
Example 1: how to set material c unity
Renderer rend = GetComponent<Renderer>();
if (rend != null){
rend.material = newMaterialRef;
}
Example 2: unity set material
gameObject.GetComponent<Renderer>().material = newMaterial;