• Unity
  • Timing of SkeletonAnimation.OnRebuild

  • Изменено
Related Discussions
...

We set the SkeletonDataAsset (we load the correct resolution variant from Addressables) then give it to SkeletonAnimation on runtime by following the advice here: Change SkeletonDataAsset In Runtime.

However, we're having trouble with subscribing to SkeletonAnimation.AnimationState events after Initialize(true) is called on the SkeletonAnimation because the only event that is triggered, SkeletonAnimation.OnRebuild, gets called even before SkeletonAnimation.AnimationState is created.

Is there a better place to subscribe to SkeletonAnimation.AnimationState events after manually triggering Initialize()?


I just realized after posting that I can just inherit SkeletonAnimation and do my own event after AnimationState is created. But if there's a built-in way, I'm all ears. 🙂

Thanks for the input, such a callback was indeed missing. We have just added a OnAnimationRebuild callback (in this commit on 4.1-beta branch) which is issued after AnimationState has been initialized.

A new 4.1-beta unitypackage is available for download here as usual:
Spine Unity Download: spine unity 4.1 beta

changelog.md написал
  • SkeletonAnimation, SkeletonMecanim and SkeletonGraphic now provide an additional OnAnimationRebuild callback delegate which is issued after both the skeleton and the animation state have been initialized.

Note the slight change in behaviour of SkeletonGraphic.OnRebuild:

changelog.md написал
  • Breaking changes
  • SkeletonGraphic OnRebuild callback delegate is now issued after the skeleton has been initialized, before the AnimationState component is initialized. This makes behaviour consistent with SkeletonAnimation and SkeletonMecanim component behaviour. Use the new callback OnAnimationRebuild if you want to receive a callback after the SkeletonGraphic AnimationState has been initialized.

That was quick! Thank you, Spine team! 🙂

You're welcome, thanks for reporting. 🙂