tony01

if (collectToasterSpine == null)
{
collectToasterSpine = Instantiate(ToasterSpine);
collectToasterSpine.transform.SetParent(Root.transform);

}
collectToasterSpine.transform.localPosition = new Vector3(4, 2, 0);
if (collectToasterAnimation == null)
{
collectToasterAnimation = collectToasterSpine.GetComponent<SkeletonAnimation>();
collectToasterAnimation.clearStateOnDisable = true;
//设置true 首帧偶现显示stup状态 设置为false 首帧显示path最后一帧
}
if (!collectToasterAnimation.enabled)
{
collectToasterAnimation.enabled = true;
}

TrackEntry trackEntry = collectToasterAnimation.state.SetAnimation(0, "path", false);
trackEntry.Complete += (TrackEntry entry) =>
{
collectToasterSpine.transform.localPosition = new Vector3(5, 2, 0);
collectToasterAnimation.enabled = false;
};
第一次播放没有问题 在第二次播放的时候首帧显示错误 请问是什么原因导致的
tony01
  • 帖子: 4

Harald

您能否分享有问题的框架的屏幕截图,并更详细地描述显示不正确的内容? 请同时显示应该显示的内容。
Could you please share a screenshot of the problematic frame, and describe in more detail what is displayed incorrectly? Please also show what should be displayed instead.
头像
Harald

Harri
  • 帖子: 4174

tony01

当选用animation.clearStateOnDisable = true;是存在首帧显示


正确的显示应该为
tony01
  • 帖子: 4

Harald

感谢您的附加信息。看起来好像附件可见性仍设置为设置姿势并且尚未应用动画。

您是否正在使用较旧的 spine-unity 运行时?

所需步骤应如 this论坛主题
根据您发出实例化调用的位置(例如,来自协程等),它可能会在 LateUpdate() 之前缺少对 Update() 的调用。

因此,您可以在实例化调用之后添加以下内容:
[代码]
GameObject instance = Instantiate(clickEffectPre, transform);
var SkeletonAnimation = instance.GetComponent<SkeletonAnimation>();
骨架动画.更新(0); // 这行应该有帮助
骨架动画.LateUpdate(); // 你也可以检查这个额外的行是否也是必要的
[/代码]

这个线程更详细地解释了它:
How to set first frame before animation starting in Unity?
-----

Thanks for the additional information. It looks as if attachment visibility is still set to the setup pose and the animation has not been applied yet.

Are you perhaps using an older spine-unity runtime?

The required steps should be as described on this forum thread:
Depending on where you are issueing the instantiation call (e.g. from coroutines, etc.), it might be missing a call to Update() before LateUpdate().

So you could add the following after your instantiation call:
GameObject instance = Instantiate(clickEffectPre, transform);
var skeletonAnimation = instance.GetComponent<SkeletonAnimation>();
skeletonAnimation.Update(0); // this line should help
skeletonAnimation.LateUpdate(); // you could also check if this additional line is also necessary
This thread explains it in more detail:
How to set first frame before animation starting in Unity?
头像
Harald

Harri
  • 帖子: 4174


回到 中国Spine用户