How can I retrieve the animation clips inside an animation fbx file?

I’m trying to get all the animation clips stored inside an fbx file. The fbx file is an asset, NOT a Game Object, i.e: it shows in the project’s window, not in the hierarchy.

What I want is a method to access the Motion object in the animation file, as I’m building an script to automatically map motions to mecanim states/animationclips given a set of filename named with some conventions.

I’ve tried:

  • Accessing the motion inside the fbx file directly. Unfortunatley the fbx file is of type UnityEngine.Object and does not includes an Component of type Animation.

  • Instantiating the fbx file in the scene (so I create a proper GameObject from that asset) and then accessing the GameObject.animation property. Unfortunately when I instantiate it the resulting GameObject in the hierarchy, it does not contains an Animation Component neither so I’m pretty stuck.

Any ideas?

Here , You can find a script that copies the animation curves from an imported .fbx file into unity animation. The script creates a read/write copy of the animation in the same folder.
It treats the fbx files as assets so it might prove useful.

As accepted from OP the line :

AssetDatabase.LoadAsset(path, typeof(AnimationClip));

proves to be helpful.