• 周四. 6月 30th, 2022

5G编程聚合网

5G时代下一个聚合的编程学习网

热门标签

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

admin

11月 28, 2021

直接看效果,修改前为:

修改后为:

工具代码如下:

 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

发表评论

您的电子邮箱地址不会被公开。