Beispiel #1
0
 public static void Play(this DAnimatorComponent self, DMotionType motionType, float motionSpeed = 1f)
 {
     if (!self.HasParameter(motionType.ToString()))
     {
         return;
     }
     self.MotionType   = motionType;
     self.MontionSpeed = motionSpeed;
 }
Beispiel #2
0
        public static float AnimationTime(this DAnimatorComponent self, DMotionType motionType)
        {
            AnimationClip animationClip;

            if (!self.animationClips.TryGetValue(motionType.ToString(), out animationClip))
            {
                throw new Exception($"找不到该动作: {motionType}");
            }
            return(animationClip.length);
        }
Beispiel #3
0
        public static void PlayInTime(this DAnimatorComponent self, DMotionType motionType, float time)
        {
            AnimationClip animationClip;

            if (!self.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;
            }
            self.MotionType   = motionType;
            self.MontionSpeed = motionSpeed;
        }