• RuntimesUnity
  • When the animation duration played is 0, performance is still consumed.

Our project has a large number of spine objects. Their default animation duration is 0. It may be switched to other normal animations. How to turn off the consumption of animation duration 0?
I tried to judge the duration of the animation to close the SkeletonAnimation component (SkeletonAnimation.enabled = false), but this resulted in the inability to update to the new animation when switching animations. I tried many forced update interfaces and methods, but none worked. I could only delay to update the animation, asynchronous operations bring some risks. How do I update the animation when SkeletonAnimation.enabled = false?
Thanks for your answer!
_Version: Unity Spine3.8
@Harald

Related Discussions
...

To address the issue of performance consumption by animations with a duration of 0 in your project, you can consider a strategy similar to what was discussed in the [spine-c] 3.5 - animation jerking context. Specifically, you can check if the animation's duration is 0 and, if so, avoid setting a new animation every frame or re-enabling the SkeletonAnimation component unnecessarily. This approach aims to minimize unnecessary updates and performance overhead.

However, since you've encountered issues with updating to a new animation when the SkeletonAnimation component is disabled, you might need to implement a more nuanced approach. One potential solution could be to only disable the SkeletonAnimation component when you're certain that the animation with a duration of 0 will be playing for a while and re-enable it just before switching to a new animation. This could be done by monitoring the game state or the specific conditions under which animations are switched in your game.

Unfortunately, without direct support for this scenario in the Spine-Unity runtime, you may need to manually manage the enabling and disabling of the SkeletonAnimation component based on your game's logic and the timing of animation switches. This approach requires careful consideration of the timing and conditions under which the component is enabled or disabled to ensure smooth transitions between animations.

  • chuan ответили на это сообщение.

    Spinebot
    Thank you very much for your reply. According to your tips, I got the answer to the question in the example of "Spine Examples/Other Examples/FixedTimestepUpdates".

    skeletonAnimation.Update(deltaTime);
    skeletonAnimation.LateUpdate();
    skeletonAnimation.enabled = false;

    The animation can be updated, but the deltaTime needs to be large enough to update to the target action. I guess this has something to do with the mixing of the animation. The above code can directly switch to other animations when closing the script.