protected void ExecuteOnceInNormalizedTime(int index, Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { AnimStateComponent component = componentList[index]; if (!_hasExecuted[index]) { if (_currentTime >= component.normalizedStart) { component.ComponentEnter(animator, stateInfo, layerIndex); component.ComponentUpdate(animator, stateInfo, layerIndex); component.ComponentExit(animator, stateInfo, layerIndex); _hasExecuted[index] = true; } } }
protected void UpdateInNormalizedRange(int index, Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { AnimStateComponent component = componentList[index]; if (!_islooping[index] && _currentTime >= component.normalizedStart && _currentTime <= component.normalizedEnd) { component.ComponentEnter(animator, stateInfo, layerIndex); _islooping[index] = true; } else if (_islooping[index] && _currentTime >= component.normalizedEnd) { component.ComponentExit(animator, stateInfo, layerIndex); _islooping[index] = false; } else if (_currentTime >= component.normalizedStart && _currentTime <= component.normalizedEnd) { component.ComponentUpdate(animator, stateInfo, layerIndex); } }
public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { base.OnStateUpdate(animator, stateInfo, layerIndex); if (stateInfo.normalizedTime > 1.0f) { return; } _currentTime = stateInfo.normalizedTime; for (int i = 0; i < componentList.Count; i++) { AnimStateComponent cmp = componentList[i]; if (!cmp.IsExecuteOnceInState()) { UpdateInNormalizedRange(i, animator, stateInfo, layerIndex); } else { ExecuteOnceInNormalizedTime(i, animator, stateInfo, layerIndex); } } }