• RuntimesUnity
  • 游戏运行中,是否可以切换SkeletonDataAsset

@fengmin You can register your own components to the skeletonAnimation.OnAnimationRebuild callback to get notified when Initialize(true) invalidates e.g. your skeleton and AnimationState.

skeletonAnimation.OnAnimationRebuild -= InitializeOnRebuild;
..

protected void InitializeOnRebuild (ISkeletonAnimation animatedSkeletonComponent) {
	Initialize();
}

You can find the same code in SkeletonRootMotionBase.cs:
EsotericSoftware/spine-runtimesblob/4.2/spine-unity/Assets/Spine/Runtime/spine-unity/Components/RootMotion/SkeletonRootMotionBase.cs#L179

Related Discussions
...

在使用SkeletonRootMotion我发现骨骼会在动画最后一帧时,回到动画的初始位置,同时使用BoneFollower 的时候,就会出现Follow的物品跟着闪烁一下,有什么办法解决吗

When using SkeletonRootMotion, I found that the skeleton will return to the initial position of the animation at the last frame of the animation.

Could you please describe that in more detail, when exactly does that happen? If it happens all the time, then root motion is not active (for whatever reasons not doing anything). Or does it revert to the initial position only once after changing your SkeletonDataAsset?

When using BoneFollower at the same time, the Follow items will flash. Is there any solution?

Could you please describe what exactly happens? It has been translated as "flash", do you mean the BoneFollower object's position is wrong for a single frame?

    Harald 抱歉,我得更正一点,不是使用BoneFollower时,是使用SkeletonUtility的Follow All Bones的时候
    当动画循环播放时,例如跑步动画,会在动画的最后一帧到第一帧的时候,骨架会回到原位一帧的时间
    设置如下


    或者会不会是我的动画本身有问题,我在动画中移动的是RoleRoot节点的坐标并且将其作为了其他节点的父对象

      @fengmin Thanks for the additional info. Is your run animation three cycles long in a single animation? The issue seems to occurs only after the third cycle.

      How is the GameObject transform position moving? Unfortunately the video shows the RectTransform tool active, with no RectTransform borders visible either. Could you please share a video where the Translate tool is active, so that we can see the GameObject origin moving?

        Harald
        视频中的动画循环了3次,该问题是每次都触发,只是由于视频帧数您只能在我暂停的第三次看见该现象

        fengmin 或者会不会是我的动画本身有问题,我在动画中移动的是RoleRoot节点的坐标并且将其作为了其他节点的父对象

        GameObject本身的位移是没有发生回溯的,只有骨骼发生了回溯,抱歉不知道为什么录屏的鼠标位置有向上偏移,请留意鼠标下方和实际选中的对象

        @fengmin Thanks for the additional information and videos. This indeed looks strange, we have not yet encountered such an issue. Could you please send us a minimal Unity project which still shows this issue? You can send it as a zip package to contact@esotericsoftware.com, briefly mentioning this forum thread URL so that we know the context. Then we can have a look at what's going wrong.

          Harald 压缩包已经发送到邮箱了,辛苦您了
          另外,我还是对游戏运行中切换SkeletonDataAsset的实现方法没有头绪
          目前我发现使用Reload按钮是最完美切换方式,但是我不知道如何在代码中调用该按钮或者编写和Reload按钮功能相似的方法

            fengmin Harald 压缩包已经发送到邮箱了,辛苦您了

            Thanks for sending the reproduction project. We received everything. Please note that you should not add the project to Unity Version Control when sending it as a reproduction project. I had to manually remove the Unity Collaboration package to fix any errors. Nevertheless, I could now reproduce your issue. We will get back to you here on the forum once we know what's going wrong.

            fengmin 目前我发现使用Reload按钮是最完美切换方式,但是我不知道如何在代码中调用该按钮或者编写和Reload按钮功能相似的方法

            Please check out this recent forum posting here:
            https://esotericsoftware.com/forum/d/26544-reload-skeletondataasset-in-runtime/2
            Or this one for SkeletonGraphic (which also shows setting initialSkinName and startingAnimation)https://esotericsoftware.com/forum/d/26432-skeletondataasset-swap-in-runtime-has-blue-tint/2

            @fengmin We have just released a bugfix for SkeletonUtilityBone updating too late (before SkeletonRootMotion moves the bone back).

            A new spine-unity 4.2 unitypackage is available for download here as usual:
            https://esotericsoftware.com/spine-unity-download
            Please let us know whether this fixes the issue on your end as well. Thanks for reporting.

            Issue ticket URL for later reference:
            EsotericSoftware/spine-runtimes2582

              Harald
              非常感谢,问题成功得到了解决

              @fengmin Glad to hear, thanks for getting back to us.