- 수정됨
Seeing flash of Setup sprites when using a coroutine
Hi there,
I use a coroutine to delay activating a Spine skeleton. Once called, I update the skin and then set the animation. The first time the animation plays, I see a brief flash of sprites in their "Setup" position. I have figured out that to stop the flash, I need to call:
_spineAnimationState.Apply(_spineSkeleton);
After both the skin and animation is set. Usually I do this as part of my UpdateSkin method. However I wondered if I'm possible doing this incorrectly?
Actually it looks like calling Apply afterwards doesn't actually solve it.
After you change the skin, call both
skeleton.SetSlotsToSetupPose(); // refresh attachments based on setup pose.
animationState.Apply(skeleton); // refresh attachments based on currently active slot and deform keys.
Yep, both of those are at the end of my UpdateSkin method:
void UpdateSkin(string feedbackName) {
_skin = _skin ?? new Skin("Feedback");
_skin.Clear();
_skin.Append(_spineSkeleton.Data.FindSkin(feedbackName));
_spineSkeleton.SetSkin(_skin);
_spineSkeleton.SetSlotsToSetupPose();
_spineAnimationState.Apply(_spineSkeleton);
}
The issue is present with them there. But it's only the first time I show it.
Ah, since this involves enabling the SkeletonAnimation for the first time, you may also need to call skeletonAnimation.LateUpdate after all that.
skeletonAnimation.LateUpdate(); // refresh the UnityEngine.Mesh and materials being used by the GameObject.
This is really only necessary if for some reason, the SkeletonAnimation is rendered before you are able to make any changes to it. Depending on your coroutine code and the order in which you enable/disable things, this may be the case.