- Đã chỉnh sửa
无法切换动画
我通过替换 skeletonDataAsset 资源的方式切换动画,但是没有成功。
如下图以及代码所示,我点击按钮调用下面的函数,替换 skeletonDataAsset 动画资源,以达到切换动画的效果,但是没有成功
public void ButtonCallBack()
{
if (animeIndex == 0)
{
sg.skeletonDataAsset = Bundle.LoadAsset("spineAsset1_SkeletonData") as SkeletonDataAsset;
sg.Initialize(false);
sg.AnimationState.SetAnimation(0, "anim1", true);
animeIndex++;
print(1);
}
else if (animeIndex == 1)
{
sg.skeletonDataAsset = Bundle.LoadAsset("spineAsset2_SkeletonData") as SkeletonDataAsset;
sg.Initialize(false);
sg.AnimationState.SetAnimation(0, "anim1", true);
animeIndex
---
;
print(2);
}
}
当替换一个已经加载的 SkeletonDataAsset
时,你需要在 Initialize (bool overwrite)
处传递 true
。当传递 false
时,它不会做任何事情,因为它已经加载了一个有效的骨架(旧的)。
When replacing an already loaded SkeletonDataAsset
you need to pass true
at Initialize(bool overwrite)
. When passing false
it does nothing, since it already has a valid skeleton loaded (the old one).
Harald đã viết当替换一个已经加载的
SkeletonDataAsset
时,你需要在Initialize (bool overwrite)
处传递true
。当传递false
时,它不会做任何事情,因为它已经加载了一个有效的骨架(旧的)。When replacing an already loaded
SkeletonDataAsset
you need to passtrue
atInitialize(bool overwrite)
. When passingfalse
it does nothing, since it already has a valid skeleton loaded (the old one).
非常感谢,这个问题已经解决,但遇到了新的问题:http://zh.esotericsoftware.com/forum/x-14308?p=62954#p62954
请帮忙,谢谢!