Hii !
I am having some issues with changing the color of a material by scripting
i’m creating a cube .
i wrote this code :
void Update () {
gameObject.GetComponent().material.color = Color.blue;
}
but it doesn’t work ??
thank you !
Hii !
I am having some issues with changing the color of a material by scripting
i’m creating a cube .
i wrote this code :
void Update () {
gameObject.GetComponent().material.color = Color.blue;
}
but it doesn’t work ??
thank you !
Good day.
You are not accessing any component. Do this
gameObject.GetComponent<MeshRenderer>().material.color = Color.blue;
Bye!