← All dev blog posts

Changing GameObject Material by Script - Unity

23 June 2020

Basically you just need to access the material property of the Renderer component.

public Material yourMaterial;

gameobject.GetComponent<Renderer> ().material = yourMaterial;