This is probably not going to work straight off. The internal counters would have overflowed if you switch the wrap mode at runtime. There are a few different ways to do this. I'll describe one possible way.
You set a trigger on the last frame of your animation.
In an attached behaviour, attach an animationEventDelegate and in the function, do something like this....
void animationEventDelegate(...)
{
if (stopAfterLoop == true)
{
var clip = animatedSprite.CurrentClip;
var lastFrame = clip.frames[clip.frames.Length - 1];
animatedSprite.Stop(); // stop the animated sprite
animatedSprite.SwitchCollectionAndSprite(lastFrame.spriteCollection, lastFrame.spriteId);
}
}
Instead of changing the clip, you simply set stopAfterLoop = true, and this will stop the animation after the current iteration.
The reason the SwitchCollectionAndSprite line is required is that the trigger could have fired a few animation frames ago (depending on the speed of your animation), and the currently displayed frame could be a different one.
Ideally all you'd need to do is do animatedSprite.Stop(); animatedSprite.SetFrame(frameNum); but with the current API, it'll trigger the event recursively will be really bad!
There were a few issues with calling stop from a callback in one of the previous versions. All of these have been fixed (to the best of my knowledge) in 1.76b1, so drop me an email if you run into any issues and let me know the version you're on - I should be able to sort out a patch.