• RuntimesUnityBugs
  • Skeleton Graphic shows atlas if animation is frozen right after initialisation

Problem statement

Hi,

Recently upgraded to 4.1 from 3.8 and we have a specific issue that only appears after the upgrade.
We are using the following code to freeze a SkeletonGraphic on the first frame of the animation

void OnEnable()
{
            m_skeletonGraphic.Initialize(true);
            m_skeletonGraphic.AnimationState.SetAnimation(0, animation, false);
            m_skeletonGraphic.freeze = true;
}

It used to work perfectly, now the graphic just shows the entire atlas used in the material instead.
If we put this code into a Coroutine and WaitForEndOfFrame before freezing, it works again, but that is not ideal.
Also tried to call .Update(), .Rebuild() before freeze, to no avail.

Thanks for your help

Runtime information

Using Spine 4.1

Related Discussions
...

I wonder why this worked in spine-unity 3.8.

Setting an animation only sets it to be applied in the next AnimationState update. You still need to apply the animation to the skeleton, which is automatically done in Update(), and then update the mesh which is automatically done in LateUpdate().

You can perform both of these necessary steps by calling
skeletonGraphic.LateUpdate();
which automatically calls Update(0) if it has not been called since initialization. After that you can freeze the skeleton.

Since you called m_skeletonGraphic.Initialize(true); with argument overwrite = true: There should be no need to re-initialize it completely, so a call to m_skeletonGraphic.Initialize(false); should be sufficient and save some loading time.

Well, LateUpdate does fix everything. It was probably one of the last things I didn't try 😅
Thanks for your help

Glad to hear you've figured it out, thanks for getting back to us!