@linhan Sorry for the delay! Unfortunately a clean suits-all API change or implementation has not been added yet.
Nevertheless, you could use a script like the following to set the SkeletonAnimation.UpdateMode to UpdateMode.OnlyAnimationStatus (this will skip events) or UpdateMode.OnlyEventTimelines to raise events during being "disabled". While this is not 100% free, it saves the majority of the update cost.
using Spine.Unity;
using UnityEngine;
public class FixedTimestepSkeletonAnimation : MonoBehaviour {
#region Inspector
public SkeletonAnimation skeletonAnimation;
[Tooltip("The duration of each frame in seconds. For 12 fps: enter '1/12' in the Unity inspector.")]
public float frameDeltaTime = 1 / 15f;
[Header("Advanced")]
[Tooltip("The maximum number of fixed timesteps. If the game framerate drops below the If the framerate is consistently faster than the limited frames, this does nothing.")]
public int maxFrameSkip = 4;
[Tooltip("If enabled, the Skeleton mesh will be updated only on the same frame when the animation and skeleton are updated. Disable this or call SkeletonAnimation.LateUpdate yourself if you are modifying the Skeleton using other components that don't run in the same fixed timestep.")]
public bool frameskipMeshUpdate = true;
[Tooltip("This is the amount the internal accumulator starts with. Set it to some fraction of your frame delta time if you want to stagger updates between multiple skeletons.")]
public float timeOffset;
#endregion
float accumulatedTime = 0;
void OnValidate () {
skeletonAnimation = GetComponent<SkeletonAnimation>();
if (frameDeltaTime <= 0) frameDeltaTime = 1 / 60f;
if (maxFrameSkip < 1) maxFrameSkip = 1;
}
void Awake () {
accumulatedTime = timeOffset;
}
void Update () {
accumulatedTime += Time.deltaTime;
float frames = 0;
while (accumulatedTime >= frameDeltaTime) {
frames++;
if (frames > maxFrameSkip) break;
accumulatedTime -= frameDeltaTime;
}
if (frames > 0) {
skeletonAnimation.UpdateMode = UpdateMode.FullUpdate;
}
else {
skeletonAnimation.UpdateMode = UpdateMode.OnlyAnimationStatus;
//skeletonAnimation.UpdateMode = UpdateMode.OnlyEventTimelines;
}
}
}