how to define a material in script unity code example
Example 1: c# change material in code
currentObject.GetComponent<Renderer>().material = materialToAssign;
Example 2: unity set material
gameObject.GetComponent<Renderer>().material = newMaterial;