Change 2D-sprite of an gameobject that has animator attached

Hello! I would like to change the sprites of an gameobject while runtime. The problem is, the gameobject has a animator with some animationen states attached to it, so I cant change the sprite with GetComponent.sprite. I want to change the sprites of the gameobject randomly when its animator is in a state where no animation clip is attached to. Do you have any ideas? Thx!

You need to set it in LateUpdate which runs after the animation update.

Thx, that works but unfortuently the my algorithm that changes the sprite runs to fast on LastUpdate. I dont know why. When it runs from animation update (I tried the algorithm with an gameobject that has no animator attached to it) it is running good.

Run your algorithm whenever you want, store the Sprite, then assign it in LateUpdate.