Synty家的POLYGON模型-Mixamo 动画处理
Mixamo的操作:
- 上传POLYGON模型
- 选择动画,然后下载
处理脚本:
//处理动画的3个Bake Into Pose
var path = AssetDatabase.GUIDToAssetPath(guid);
var importer = AssetImporter.GetAtPath(path);
if (importer is ModelImporter modelImporter)
{
modelImporter.animationType = ModelImporterAnimationType.Human;
ModelImporterClipAnimation[] clips = modelImporter.clipAnimations;
if (clips.Length == 0)
{
clips = modelImporter.defaultClipAnimations;
}
foreach (var clipAnimation in clips)
{
clipAnimation.lockRootRotation = true;
clipAnimation.lockRootHeightY = true;
clipAnimation.lockRootPositionXZ = true;
}
modelImporter.clipAnimations = clips;
}
//修改骨骼源
var path = AssetDatabase.GUIDToAssetPath(guid);
var importer = AssetImporter.GetAtPath(path);
if (importer is ModelImporter modelImporter)
{
temp.Add(modelImporter);
modelImporter.avatarSetup = ModelImporterAvatarSetup.CopyFromOther;
modelImporter.sourceAvatar = /*这里是在Mixamo中上传模型的Avatar,如果使用Create模式,那一些动画的会错误*/;
}