public static float Play(this UnityEngine.Animation anim, string clipName = null, bool forward = true) { AnimationState animState = anim.GetAnimState(clipName); if (animState != null) { if (forward) { animState.time = 0; animState.speed = Mathf.Abs(animState.speed); } else { animState.time = animState.length; animState.speed = -Mathf.Abs(animState.speed); } anim.Play(animState.name); return(animState.length); } return(0); }