Assigning a material in animation does not allow material management by code

Good morning,

I have an animation that assigns new materials to the mesh.
These materials undergo a variation of emission intensity via code.

The program that changes the intensity and the materials work well if I use them WITHOUT animations.

The problem is combined with the management of the animation with materiali and material properties.

here you can see a short video: Video example

You will notice that, at the beginning, only one material is instantiated: I did nothing, I left the material settings as they are and the GPU Instantiate parameter is TRUE.

If I change an animation parameter (for example Write default) it starts working and the materials are instantiated.

What am I doing wrong?