I've made a script for changing color of an object.
GetComponent<Renderer>().material.color
It works very well at first, but doesn't work any more after I've added 'rigidbody' component to the object.
I don't know why it happens.

upper image shows the cube has changed its color after its rigidbody component removed.
Suddenly, I noticed that it's a child of prefab.
In prefab viewer(?), I've added rigidbody component and uncheck 'gravity'
Now, it works.
The cube has changed its color even if it owns rigidbody component.