Creating dynamic 2D animations in Unity

Hi,

I have a bunch (actually lot) of spritesheets that hold character and environment animations.
Can I create animations from sprite sheets dynamically on the run? Or they have to be created manually in editor beforehand and then applied on runtime?

For example.
I have an empty game object - which is set in editor in a place where animation should be played. Depending on circumstances a script decides which idle tree animation should be played there.
I have 4 spritesheets with animated trees: dry desert tree, normal green tree, showy tree and a bush.
Can I make and play animations from these sprites without creating animations by hand?

On the other thought. Even if there is a possibility to create animations on the run - it’s not so good on performance. I think it’ll be better to create animations beforehand and swap them on the run.