Ejemplo n.º 1
0
        public void Set(AnimatorMotionType motionType, float motionSpeed = 1f)
        {
            if (!this.HasParameter(MotionType.ToString()))
            {
                return;
            }

            this.MotionType = motionType;

            this.MontionSpeed = motionSpeed;
        }
Ejemplo n.º 2
0
        /// <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);
        }
Ejemplo n.º 3
0
        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;
        }