how to assign material in unity script 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;