Previewing mecanim animation through script

I would like to preview an animation clip on a mesh in my scene view.
To preview an animation clip on an object that has an Animation component on it it’s quite simple I just use the SampleAnimation method (Unity - Scripting API: AnimationClip.SampleAnimation).

However I would like to sample an animation from an Animator component and I found no methods to preview the animation clip on the object. How can I do so?

I don’t need to do this in playmode. Just in the editor.
Ideally I’d give it a sample time, the animationClip to play and the object to play it on.

If you don’t need to preview blend trees or transitions and simply want to preview an animation clip, you can use this:

1 Like