Texture scroll stop when color change

Hi everyone,
I create a 3D plateform game. I have a cube which have two differents textures: one for the upper face and one for the others faces. This cube have a little script which scroll the upper texture:

public class ScrollingTexture : MonoBehaviour
{
    public float scrollSpeedZ = 0.90f;
    public float scrollSpeedX = 0.90f;
    public Material mat;
    private void FixedUpdate()
    {

        float offset = Time.time * scrollSpeedZ;
        float offset2 = Time.time * scrollSpeedX;
        mat.mainTextureOffset = new Vector2(offset2, -offset);
    }
}

This works well but the player can also change the materials color of this cube:

public void SetColor(Color color)
    {
        foreach ( Material m in GetComponent<Renderer>().materials)
        {
            m.color = color;
        }
    }

And when SetColor is called, the texture scrolling is stopped… Whereas mat.mainTextureOffset is still evolving !

What is going on? Thanks

have you tried to call GetComponent<Renderer>().sharedMaterials? I believe the problem comes from the fact that calling materials will instantiate each material, thus the mat.mainTextureOffset change the offset of the texture on the original material, not on the instances.