Example #1
0
 public static void PlayState(this AnimatorComponent com, int stateNameHash, int layer, float normalizedTime)
 {
     if (com.animator != null)
     {
         com.animator.Play(stateNameHash, layer, normalizedTime);
     }
 }
Example #2
0
 public static void SetParam(this AnimatorComponent com, int id, float value, float dampTime, float deltaTime)
 {
     if (com.animator != null)
     {
         com.animator.SetFloat(id, value, dampTime, deltaTime);
     }
 }
Example #3
0
 public static void SetParam(this AnimatorComponent com, int id)
 {
     if (com.animator != null)
     {
         com.animator.ResetTrigger(id);
     }
 }
Example #4
0
 public static void SetParam(this AnimatorComponent com, int id, int value)
 {
     if (com.animator != null)
     {
         com.animator.SetInteger(id, value);
     }
 }
Example #5
0
 public static void SetSpeed(this AnimatorComponent com, float speed)
 {
     if (com.animator != null)
     {
         com.animator.speed = speed;
     }
 }
Example #6
0
 public static void SetParam(this AnimatorComponent com, int id, bool value)
 {
     if (com.animator != null)
     {
         com.animator.SetBool(id, value);
     }
 }
Example #7
0
 public static void SetApplyRootMotion(this AnimatorComponent com, bool active)
 {
     if (com.animator != null)
     {
         com.animator.applyRootMotion = active;
     }
 }
Example #8
0
 public static void SetApplyCullMode(this AnimatorComponent com, AnimatorCullingMode mode)
 {
     if (com.animator != null)
     {
         com.animator.cullingMode = mode;
     }
 }
Example #9
0
 public static void SetActive(this AnimatorComponent com, bool active)
 {
     if (com.animator != null)
     {
         com.animator.enabled = active;
     }
 }
Example #10
0
 public static void SetRuntimeAnimatorController(this AnimatorComponent com, AnimatorOverrideController controller)
 {
     if (com.animator != null)
     {
         com.animator.runtimeAnimatorController = controller;
     }
 }
Example #11
0
 public static RuntimeAnimatorController GetRuntimeAnimatorController(this AnimatorComponent com)
 {
     if (com.animator != null)
     {
         return(com.animator.runtimeAnimatorController);
     }
     return(null);
 }
Example #12
0
 public static AnimationClip GetAnimationClipWithRuntimeController(this AnimatorComponent com, string clipName)
 {
     if (com.animator != null && com.animator.runtimeAnimatorController != null)
     {
         var controller = com.animator.runtimeAnimatorController as AnimatorOverrideController;
         if (controller != null)
         {
             return(controller[clipName]);
         }
     }
     return(null);
 }
Example #13
0
 public static void CrossFade(this AnimatorComponent com, int stateHashName, float normalizedTransitionDuration, int layer, float normalizedTimeOffset, float normalizedTransitionTime, bool isFixedTime = false)
 {
     if (com.animator != null)
     {
         if (isFixedTime)
         {
             com.animator.CrossFadeInFixedTime(stateHashName, normalizedTransitionDuration, layer, normalizedTimeOffset, normalizedTransitionTime);
         }
         else
         {
             com.animator.CrossFade(stateHashName, normalizedTransitionDuration, layer, normalizedTimeOffset, normalizedTransitionTime);
         }
     }
 }
Example #14
0
        public static void SetParam(this AnimatorComponent com, ActionParam param)
        {
            if (param == null)
            {
                return;
            }

            switch (param.ParamType)
            {
            case AnimatorParamType.INTEGER:
                com.SetParam(param.ParamNameHash, param.IntegerValue);
                break;

            case AnimatorParamType.FLOAT:
                com.SetParam(param.ParamNameHash, param.FloatValue);
                break;

            case AnimatorParamType.LERP_FLOAT:
                com.SetParam(param.ParamNameHash, param.FloatValue, param.lerpTime, Time.deltaTime);
                break;

            case AnimatorParamType.BOOL:
                com.SetParam(param.ParamNameHash, param.BooleanValue);
                break;

            case AnimatorParamType.TRIGGER:
                com.SetParam(param.ParamNameHash);
                break;

            case AnimatorParamType.STATE:
                com.PlayState(param.ParamNameHash, param.layer, param.normalizedTime);
                break;

            case AnimatorParamType.SPEED_CONTROL:
                com.SetSpeed(param.FloatValue);
                break;

            default:
                Logger.Error("Animator start 不接受该类型的参数 name {0} type {1}", param.ParamNameHash, param.ParamType);
                break;
            }
        }
Example #15
0
 public static void SetAnimator(this AnimatorComponent com, Animator animator)
 {
     com.animator = animator;
 }