How to create animation from FBX at runtime, not in editor!

Note: Everything creating at runtime.

1)loading fbx file from assert at runtime:

GameObject go = Instantiate(Resources.Load(path)) as GameObject;

2)then apply material:

Texture texture = Resources.Load (texturePath) as Texture
SkinnedMeshRenderer renderer = GetComponentInChildren();
renderer.material.shader = Shader.Find ("Diffuse");
renderer.material.mainTexture = texture;

3)create animation clip from “Take 001”:
But how can I get animation “Take 001” from the FBX.

gameObject.animation is null.

I know, there are one way to slove this pro:
In editor inspector option, setting RIG to “legacy” mode,
the Animation component will auto attaching, and
“Take 001” will auto attaching under animations too.

But that’s no what i need, i want create animation component at run time,
but i can found a way to get animation clip from the FBX file, and attach it under animations.

By just reading your title the answer is very simple: You can’t. Unity’s FBX importer only exists in the editor. To make that clear: You can not import an FBX file at runtime.

However placing an FBX file in the resources folder of your project already imports the model in the editor. From now on the model is represented by Unity’s internal model-asset format. When you use Resources.Load you simply grab the serialized model from the assets.

The imported model is actually split up into several sub assets (which you see when you expand the actual model file). The main asset is usually a GameObject which acts as root object. However you can simply use:

// C#
AnimationClip anim = Resources.Load<AnimationClip>("MyModel");

to get the animation clip asset which is simply a sub asset. Keep in mind that there’s also the “LoadAll” method in case your model has several animations:

// C#
AnimationClip[] anims = Resources.LoadAll<AnimationClip>("MyModel");
foreach(var a in anims)
{
    Debug.Log("Animation: " + a.name);
}