public void Set(AnimatorMotionType motionType, float motionSpeed = 1f) { if (!this.HasParameter(MotionType.ToString())) { return; } this.MotionType = motionType; this.MontionSpeed = motionSpeed; }
/// <summary> /// 获取动画时间 /// </summary> /// <param name="motionType"></param> /// <returns></returns> public float GetAnimationTime(AnimatorMotionType motionType) { AnimationClip animationClip; if (this.animationClips.TryGetValue(motionType.ToString(), out animationClip)) { throw new Exception($"找不到该动作:{motionType}"); } return(animationClip.length); }
public void SetInTime(AnimatorMotionType motionType, float time = 1) { AnimationClip animationClip; if (this.animationClips.TryGetValue(motionType.ToString(), out animationClip)) { throw new Exception($"找不到该动作:{motionType}"); } float motionSpeed = animationClip.length / time; //检测是否合理 if (motionSpeed < 0.01f || motionSpeed > 1000f) { Log.Error($"motionSpeed数值异常,{motionSpeed},此动作跳过"); return; } this.MotionType = motionType; this.MontionSpeed = motionSpeed; }