The StackOverflowException you're encountering is likely due to repeatedly setting the animation in a loop without allowing the animation state to progress, especially with timeScale
set to 0. This causes an excessive buildup of mixed animations, leading to a stack overflow. To address this, you should avoid setting the animation multiple times in a single frame. Instead, set the animation once and let it complete before setting it again. You can also consider limiting the number of mixed animations by checking if an animation is already set before setting it again.
void Awake() {
skeleton.timeScale = 0;
skeleton.AnimationState.SetAnimation(0, "animation", false);
}
public SkeletonGraphic skeleton;
public void Update() {
// Ensure the animation is only set once
if (skeleton.AnimationState.GetCurrent(0) == null) {
skeleton.AnimationState.SetAnimation(0, "animation", false);
}
}
This approach ensures that you don't repeatedly set the same animation, which should help prevent the stack overflow issue.