How should I on/off animation loop on mecanim in script?

Hi, All.
How should I on/off animation loop on mecanim in script? I use generic animation.
I tested AnimationClip.wrapmode, It doesn’t work.
Thanks in advance.

Double click on the animation state and un check “Loop Time” check box.

Thanks.

You can now use AnimationUtility.SetAnimationClipSettings, i.e.

var settings = AnimationUtility.GetAnimationClipSettings(clip);
settings.loopTime = m_Looping;
AnimationUtility.SetAnimationClipSettings(clip, settings);

By default a state will keep looping.

To make it stop looping, create a transition to another state.

To resume looping, create a transition back to the loop state.