bool CheckAnimStateChanged(out int stateHash, out float normalizedTime, int layerId) { bool change = false; stateHash = 0; normalizedTime = 0; float lw = animator.GetLayerWeight(layerId); if (Mathf.Abs(lw - layerWeight[layerId]) > 0.001f) { layerWeight[layerId] = lw; change = true; } if (animator.IsInTransition(layerId)) { AnimatorTransitionInfo tt = animator.GetAnimatorTransitionInfo(layerId); if (tt.fullPathHash != transitionHash[layerId]) { // first time in this transition transitionHash[layerId] = tt.fullPathHash; animationHash[layerId] = 0; return(true); } return(change); } AnimatorStateInfo st = animator.GetCurrentAnimatorStateInfo(layerId); if (st.fullPathHash != animationHash[layerId]) { // first time in this animation state if (animationHash[layerId] != 0) { // came from another animation directly - from Play() stateHash = st.fullPathHash; normalizedTime = st.normalizedTime; } transitionHash[layerId] = 0; animationHash[layerId] = st.fullPathHash; return(true); } return(change); }