Unity之如何使用工具修改fbx 动画的设置

直接看效果,修改前为:

Unity之如何使用工具修改fbx 动画的设置

修改后为:

Unity之如何使用工具修改fbx 动画的设置

工具代码如下:

 1     [MenuItem("Saber/Asset/Fix Dance Anim")]
 2     static void FixDanceAnim()
 3     {
 4         UnityEngine.Object[] objs = Selection.objects;
 5         foreach (var obj in objs)
 6         {
 7             string assetPath = AssetDatabase.GetAssetPath(obj);
 8             ModelImporter importer = (ModelImporter)ModelImporter.GetAtPath(assetPath);
 9             var oldClip = importer.clipAnimations[0];
10             ModelImporterClipAnimation newClip = new ModelImporterClipAnimation();
11             newClip.name = oldClip.name;
12             newClip.loopTime = false;
13             newClip.firstFrame = oldClip.firstFrame;
14             newClip.lastFrame = oldClip.lastFrame;
15             newClip.keepOriginalPositionXZ = true;
16             newClip.keepOriginalOrientation = true;
17             newClip.keepOriginalPositionY = true;
18             newClip.lockRootRotation = false;
19             newClip.lockRootHeightY = false;
20             newClip.lockRootPositionXZ = false;
21             newClip.heightOffset = 0;
22             newClip.rotationOffset = 0;
23             ModelImporterClipAnimation[] clips = new ModelImporterClipAnimation[1] { newClip };
24             importer.clipAnimations = clips;
25             importer.SaveAndReimport();
26         }
27 
28         Debug.Log("All finished");
29     }

转载请注明出处:https://www.cnblogs.com/jietian331/p/15166591.html

上一篇:你知道地下电缆是啥样子吗?北漂小斌和你分享地下电缆线漫游视频


下一篇:FBX人形骨骼动画" 正确的转换成 "BIP动画