unity project material preview 2d code example Example: unity set material gameObject.GetComponent<Renderer>().material = newMaterial;