修改工具
This commit is contained in:
parent
208af8eab9
commit
6f1286cb4a
@ -4,7 +4,6 @@ using UnityEditor;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
using System;
|
||||
|
||||
|
||||
public class FbxAnimListPostprocessor : MonoBehaviour
|
||||
@ -16,6 +15,48 @@ public class FbxAnimListPostprocessor : MonoBehaviour
|
||||
if (null != obj)
|
||||
{
|
||||
string assetPath = AssetDatabase.GetAssetPath(obj);
|
||||
SplitAnim(assetPath);
|
||||
}
|
||||
}
|
||||
|
||||
[MenuItem("Assets/SplitAnimFloder")]
|
||||
public static void SetAplitAnim()
|
||||
{
|
||||
Object[] selectedObjects = Selection.GetFiltered<Object>(SelectionMode.DeepAssets);
|
||||
foreach (Object obj in selectedObjects)
|
||||
{
|
||||
if (obj != null)
|
||||
{
|
||||
string path = AssetDatabase.GetAssetPath(obj);
|
||||
if (Directory.Exists(path))
|
||||
{
|
||||
EnableFBXReadWriteInFolder(path);
|
||||
}
|
||||
else if (path.EndsWith(".fbx", System.StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
EnableFBXReadWriteForFile(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void EnableFBXReadWriteInFolder(string folderPath)
|
||||
{
|
||||
string[] files = Directory.GetFiles(folderPath, "*.fbx", SearchOption.AllDirectories);
|
||||
foreach (string file in files)
|
||||
{
|
||||
EnableFBXReadWriteForFile(file);
|
||||
}
|
||||
}
|
||||
|
||||
public static void EnableFBXReadWriteForFile(string filePath)
|
||||
{
|
||||
string relativePath = filePath;
|
||||
SplitAnim(filePath, true);
|
||||
}
|
||||
|
||||
|
||||
public static void SplitAnim(string assetPath, bool autoImport = false)
|
||||
{
|
||||
try
|
||||
{
|
||||
string fileAnim;
|
||||
@ -25,6 +66,20 @@ public class FbxAnimListPostprocessor : MonoBehaviour
|
||||
string sAnimList = file.ReadToEnd();
|
||||
file.Close();
|
||||
//
|
||||
if (autoImport)
|
||||
{
|
||||
System.Collections.ArrayList List = new ArrayList();
|
||||
ParseAnimFile(sAnimList, ref List);
|
||||
|
||||
ModelImporter modelImporter = ModelImporter.GetAtPath(assetPath) as ModelImporter;
|
||||
modelImporter.animationType = ModelImporterAnimationType.Legacy;
|
||||
//modelImporter.clipAnimations. = true;
|
||||
modelImporter.clipAnimations = (ModelImporterClipAnimation[])
|
||||
List.ToArray(typeof(ModelImporterClipAnimation));
|
||||
AssetDatabase.ImportAsset(assetPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (EditorUtility.DisplayDialog("FBX Animation Import from file",
|
||||
fileAnim, "Import", "Cancel"))
|
||||
{
|
||||
@ -43,10 +98,11 @@ public class FbxAnimListPostprocessor : MonoBehaviour
|
||||
+ modelImporter.clipAnimations.GetLength(0).ToString(), "OK");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch { }
|
||||
// (Exception e) { EditorUtility.DisplayDialog("Imported animations", e.Message, "OK"); }
|
||||
}
|
||||
}
|
||||
|
||||
static void ParseAnimFile(string sAnimList, ref System.Collections.ArrayList List)
|
||||
{
|
||||
|
||||
@ -27,6 +27,9 @@ public class SetReadWrite : Editor
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static void EnableFBXReadWriteInFolder(string folderPath)
|
||||
{
|
||||
string[] files = Directory.GetFiles(folderPath, "*.fbx", SearchOption.AllDirectories);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user