public void SetTrigger(AnimatorParameters varName) { Animator.SetTrigger(varName.Value); if (ParametersTriggerChange != null) { ParametersTriggerChange(this, varName); } }
public void SetInteger(AnimatorParameters varName, int value) { Animator.SetInteger(varName.Value, value); if (ParametersIntegerChange != null) { ParametersIntegerChange(this, varName, value); } }
public void SetFloat(AnimatorParameters varName, float value) { Animator.SetFloat(varName.Value, value); if (ParametersFloatChange != null) { ParametersFloatChange(this, varName, value); } }
public void SetBool(AnimatorParameters varName, bool value) { Animator.SetBool(varName.Value, value); if (ParametersBoolChange != null) { ParametersBoolChange(this, varName, value); } }
private void Awake() { Transform = GetComponent <Transform>(); Rigidbody = GetComponent <Rigidbody>(); Collider = GetComponent <Collider>(); MeshRenderer = GetComponent <MeshRenderer>(); _animator = GetComponent <Animator>(); AnimatorParameters = new AnimatorParameters(ref _animator); CharAttributes = new CharAttributes(); }
public void StoresAllTriggers() { _stub.AnimatorCtrl.AddParameter(new AnimatorControllerParameter { name = "a", type = AnimatorControllerParameterType.Trigger }); _stub.InjectCtrl(); var par = new AnimatorParameters(_stub.Animator); Assert.IsTrue(par.triggers.dic.ContainsKey("a")); }
public void OnPlayAnimation(AnimatorParameters _actionType, ActionParamtersType _ActionParamtersType, int _intValue = 1, float _floatValue = 0.0f)//播放或停止动作 { for (int i = 0; i < animatorList.Count; i++) { Animator animator = animatorList[i]; if (animator != null) { if (animator.parameterCount > (int)_actionType) { if (_ActionParamtersType != ActionParamtersType.Trigger) { animatorParameters = _actionType; } string _animatorParameterName = animator.GetParameter((int)_actionType).name; switch (_ActionParamtersType) { case ActionParamtersType.Float: if (animator.GetFloat(_animatorParameterName) != _floatValue) { animator.SetFloat(_animatorParameterName, _floatValue); } break; case ActionParamtersType.Int: if (animator.GetInteger(_animatorParameterName) != _intValue) { animator.SetInteger(_animatorParameterName, _intValue); } break; case ActionParamtersType.Bool: if (animator.GetBool(_animatorParameterName) != _intValue > 0) { animator.SetBool(_animatorParameterName, (bool)(_intValue > 0)); } break; case ActionParamtersType.Trigger: animator.SetTrigger(_animatorParameterName); break; default: break; } } else { animator.Play("Idle"); } } } }
public void StoresAllInts() { _stub.AnimatorCtrl.AddParameter(new AnimatorControllerParameter { name = "a", defaultInt = 1, type = AnimatorControllerParameterType.Int }); _stub.InjectCtrl(); var par = new AnimatorParameters(_stub.Animator); Assert.IsTrue(par.ints.dic.ContainsKey("a")); }
public void StoresAllBools() { _stub.AnimatorCtrl.AddParameter(new AnimatorControllerParameter { name = "a", defaultBool = true, type = AnimatorControllerParameterType.Bool }); _stub.InjectCtrl(); var par = new AnimatorParameters(_stub.Animator); Assert.IsTrue(par.bools.dic.ContainsKey("a")); }
public AnimatorParameters GetAnimatorParametersByName(string name) { AnimatorParameters animatorParameters = AnimatorParameters.NULL; foreach (AnimatorParameters i in Enum.GetValues(typeof(AnimatorParameters))) { if (i.ToString() == name) { animatorParameters = i; } } return(animatorParameters); }
public void OnPlayAnimation(AnimatorAction _actionType, int _intValue = 1, float _floatValue = 0.0f) { if (animatorParameters != AnimatorParameters.NULL)//说明当前有一个动作被勾选,需要重置 { OnPlayAnimation(animatorParameters, ActionParamtersType.Bool, 0); animatorParameters = AnimatorParameters.NULL; } animatorAction = _actionType; //先重置为idle状态,比如飞行状态播放其他动作必须flyidle始终勾选 OnPlayAnimation(GetAnimatorParametersByName(animationTableData.Idle), ActionParamtersType.Bool, _intValue); switch (_actionType) { case AnimatorAction.Idle: OnPlayAnimation(GetAnimatorParametersByName(animationTableData.Idle), ActionParamtersType.Bool, _intValue); break; case AnimatorAction.Walk: OnPlayAnimation(GetAnimatorParametersByName(animationTableData.Walk), ActionParamtersType.Bool, _intValue); break; case AnimatorAction.Run: OnPlayAnimation(GetAnimatorParametersByName(animationTableData.Run), ActionParamtersType.Bool, _intValue); break; case AnimatorAction.Attack: OnPlayAnimation(GetAnimatorParametersByName(animationTableData.Attack), ActionParamtersType.Trigger, _intValue); break; case AnimatorAction.Die: OnPlayAnimation(GetAnimatorParametersByName(animationTableData.Die), ActionParamtersType.Trigger, _intValue); break; case AnimatorAction.Hit: OnPlayAnimation(GetAnimatorParametersByName(animationTableData.Hit), ActionParamtersType.Trigger, _intValue); break; case AnimatorAction.Stunned: OnPlayAnimation(GetAnimatorParametersByName(animationTableData.Stunned), ActionParamtersType.Bool, _intValue); break; case AnimatorAction.Victory: OnPlayAnimation(GetAnimatorParametersByName(animationTableData.Victory), ActionParamtersType.Bool, _intValue); break; default: break; } }
public void DoesNotCrashOnNullAnimatorParameters() { _stub.InjectCtrl(); var par = new AnimatorParameters(_stub.Animator); }