代码如下:
using UnityEngine;
using UnityEditor;
public class AnimationClipTool
{
[MenuItem("AnimationClip/ExportAnimFromFBX")]
private static void GetFiltered()
{
var objects = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);
foreach (var asset in objects)
{
if (!AssetDatabase.GetAssetPath(asset).EndsWith(".FBX")) continue;
var fbxAnim =
AssetDatabase.LoadAssetAtPath(AssetDatabase.GetAssetPath(asset),
typeof(AnimationClip)) as AnimationClip;
if (!fbxAnim) continue;
var path = AssetDatabase.GetAssetPath(asset).Replace(".FBX", ".anim");
var animationClip = new AnimationClip();
EditorUtility.CopySerialized(fbxAnim, animationClip);
AssetDatabase.CreateAsset(animationClip, path);
}
AssetDatabase.Refresh();
}
}
|