标签:index delete leo pre direct serialize setpath tab select
public class ActionConvetTool { [MenuItem("ActionTools/动作处理")] public static void ActionConvert() { UnityEngine.Object[] arr = Selection.GetFiltered(typeof(UnityEngine.Object), SelectionMode.Unfiltered); for (int index = 0; index < arr.Length; index++) { string strFilePath = AssetDatabase.GetAssetPath(arr[index]); Debug.Log("filePath=" + strFilePath); ActionScriptable action = ScriptableObject.CreateInstance<ActionScriptable>(); UnityEngine.Object[] objects = AssetDatabase.LoadAllAssetsAtPath(strFilePath); if (objects == null || objects.Length == 0) { return; } for (int i = 0; i < objects.Length; i++) { if (objects[i] is AnimationClip) { action.aClip = objects[i] as AnimationClip; string strSerializeFile = "Assets/Resources/Action/"; string strDir = Application.dataPath + "/Resources/Action"; if (!Directory.Exists(strDir)) { Directory.CreateDirectory(strDir); } string strFileName = objects[i].name + ".asset"; string strFile = Application.dataPath + "/Resources/Action/" +strFileName; if (File.Exists(strFile)) { File.Delete(strFile); } AssetDatabase.CreateAsset(action, strSerializeFile+strFileName); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); break; } } } } }
注意事项:需要先选中fbx模型然后导出
标签:index delete leo pre direct serialize setpath tab select
原文地址:https://www.cnblogs.com/ylwn817/p/10249721.html