其他分享
首页 > 其他分享> > 修改 Mixamo 导出的动画名字

修改 Mixamo 导出的动画名字

作者:互联网

using UnityEditor;
using UnityEngine;

public class RenameMixamoAnimationClip
{
    //修改  Mixamo  导出的动画名字
    [MenuItem("Assets/Auto Rename Mixamo AnimationClip")]
    private static void RenameMixamoANimationClips()
    {
        var objs = Selection.gameObjects;
        if (objs == null) return;

        for (var i = 0; i < objs.Length; i++)
        {
            var assetPath = AssetDatabase.GetAssetPath(objs[i]);

            var modelImporter = (ModelImporter)AssetImporter.GetAtPath(assetPath);
            if (modelImporter == null) continue;

            var clips = modelImporter.clipAnimations; // get first clip
            if (clips == null || clips.Length == 0)
                clips = modelImporter.defaultClipAnimations;

            for (var j = 0; j < clips.Length; j++)
            {
                clips[j].name = objs[i].name;
            }

            modelImporter.clipAnimations = clips;
            modelImporter.SaveAndReimport();
        }
    }
}

标签:动画,objs,导出,clips,Mixamo,modelImporter,var,null
来源: https://blog.csdn.net/weixin_41604051/article/details/112381545