set material unity c# code example
Example 1: c# change material in code
currentObject.GetComponent<Renderer>().material = materialToAssign;
Example 2: how to set material c unity
Renderer rend = GetComponent<Renderer>();
if (rend != null){
rend.material = newMaterialRef;
}
Example 3: unity set material
gameObject.GetComponent<Renderer>().material = newMaterial;