Animation Clip关键函数
【AnimationClipSettings】
设置clip loop
AnimationClipSettings setting = AnimationUtility.GetAnimationClipSettings(clip);
setting.loopTime = true;
[tip: 通过clip.wrapMode无法设置clip 的类型]
【AnimationUtility】
clip curve 曲线key 帧数,
一般推荐预设帧数,然后设置关键帧的时间
CODE:
var rate =30
clip.frameRate =rate
//
var keyFrames = new Keyframe[8];
keyFrames[0] = new Keyframe(0, 0);
keyFrames[1] = new Keyframe((float)50 / rate , 0);
var idleCurve = new AnimationCurve(keyFrames);
//帧左侧曲线状态
AnimationUtility.SetKeyLeftTangentMode(idleCurve, 0, AnimationUtility.TangentMode.Linear);
AnimationUtility.SetKeyLeftTangentMode(idleCurve, 1, AnimationUtility.TangentMode.Linear);
//帧右侧曲线状态
AnimationUtility.SetKeyRightTangentMode(idleCurve, 0, AnimationUtility.TangentMode.Linear);
AnimationUtility.SetKeyRightTangentMode(idleCurve, 1, AnimationUtility.TangentMode.Free);
//设置一条轨道
clip.SetCurve(relativePath, typeof(SkinnedMeshRenderer), propertyName, idleCurve);
【AnimatorController】
Animator Controller 创建layer数据。因为layer是struct 结构,初始化layer 信息需要再次赋值。
var ac = new AnimatorController();
ac.layers = null;
ac.AddLayer("Default");
ac.AddLayer("Face");//表情层
//
ac.parameters = null;
var layers = ac.layers;
//Default
layers[0].defaultWeight = 1;
//FACE
layers[1].defaultWeight = 1;
ac.layers = layers;
网友评论