Convert .fbx files to .anim batch

Hello, I want to convert hundreds of external .fbx fies to .anim files via script to use in Unity. But I couldn’t figured out how to, thanks for your help.

1 Answer

1

using UnityEngine;
using UnityEditor;

public class test : MonoBehaviour {

	new AnimationClip[] animation;

	void Start(){

		animation = Resources.LoadAll<AnimationClip> ("Model");
		foreach (AnimationClip i in animation) {
			Debug.Log ("Animation: " + i.name);
			AssetDatabase.CreateAsset(i, string.Format("Assets/AnimationClips/{0}.anim", i.name));
		}
	}
}

Could you help me with this error please? Couldn't create asset file because the AnimationClip 'gesture1_sample_1' is already an asset at 'Assets/Resources/AnimationClips/gesture1_sample_1.fbx'! UnityEditor.AssetDatabase:CreateAsset(Object, String) NewBehaviourScript:Start() (at Assets/NewBehaviourScript.cs:15)

–

It seems like AnimationClip already exist. Try to change the path or delete/move gesture1_sample_1 somewhere else.

–

Can I get fbx files from an external resource like Desktop or something? I move them but still it gives the same error

–

Yes you can load it with WWW WWW www = new WWW("file://" + path);

–