Get color of a material instance

I have attached a material to a cube. I’m animating the color. The color animation runs well on the cube. However I must send the same color to LEDs. For the color data I am accessing the Material I applied to the cube. But Unity has created an instance of the material. The original material does not show the animation at all. Only the instance.
cube.GetComponent<Renderer>().material.color;
accesses the original material as well and not the instance which is used for the cube.
How can I access the cube´s material instance´s color data?

Whenever you access the “.material” property of a renderer Unity will ensure that this renderer has it’s own instance of the current material. If you want to access the shared material you should use “.sharedMaterial” instead of “.material”. Though note that chaning the sharedMaterial will actually change the material asset in your project and those changes will persist when you test inside the editor.

Finally I ended up animating virtual Unity software lights instead of materials. Unity does not instantiate the lights as it does with materials. So I could comfortably animate the color of the virtual Unity light and apply the color to a physical LED.
Earlier I used C# to code light animations within coroutines, but this is not very comfortable.