感谢我的同事提供相关思路和代码 =_=
using System.IO;
using UnityEditor;
using UnityEditor.Animations;
using UnityEngine;
public class CreatePerfabsAndAnimatorControllers : AssetPostprocessor {
//Choose Folder in Project -> Get all Fbxs -> Get the clip to make a AnimatorController -> Create a Prefab and bind the AnimatorController
[MenuItem("Tools/Create Prefab and AnimatorController")]
public static void Create() {
Object[] objects = Selection.objects;
int len = objects.Length;
if (len == 0) {
Debug.Log("请选中Project视图的文件夹进行预制件和动画控制器的生成!");
}
for (int i = 0; i < len; i++) {
string resPath = Application.dataPath.Substring(0, Application.dataPath.LastIndexOf('/')) + "/" + AssetDatabase.GetAssetPath(objects[i]);
DirectoryInfo directoryInfo = new DirectoryInfo(resPath);
SearchAllFbx(directoryInfo);
}
AssetDatabase.Refresh();