• Editor
  • Issue when replacing skeletonDataAsset

Im replacing the skeletonDataAsset as above. It only works the first time, and the only way to make it work is to dissable and enable the gameobject. I also tried using Clear() and SetAnimationState.

anim.skeletonDataAsset = bundle.LoadFromAssetBundle<SkeletonDataAsset> (id, ".asset");
anim.startingAnimation = "Idle";
anim.Initialize (true);

Related Discussions
...

Were you talking about SkeletonGraphic?

It seems to work fine, except that the CanvasRenderer doesn't refresh its main texture.
For now, to fix that, you have to go:

skeletonGraphic.canvasRenderer.SetTexture(skeletonGraphic.mainTexture);

There will be an update soon that will remove this requirement.

For SkeletonRenderer and its derived classes, it seems to work fine.

Yes its a SkeletonGraphic, but I've tried it and seems not to work. Is there any other way or consideration? here is the whole code (original):

string id = client.ProfilePath.ToString();

ProfileSkeleton.Clear();
ProfileSkeleton.skeletonDataAsset = SAssetBundles.LoadFromAssetBundle<SkeletonDataAsset> ("profile/" + id, id, ".asset"); 
ProfileSkeleton.Initialize(true);
ProfileSkeleton.AnimationState.SetAnimation(0, "animation", true);
ProfileSkeleton.Clear();
ProfileSkeleton.skeletonDataAsset = SAssetBundles.LoadFromAssetBundle<SkeletonDataAsset> ("profile/" + id, id, ".asset");
ProfileSkeleton.Initialize(true);
ProfileSkeleton.canvasRenderer.SetTexture(ProfileSkeleton.mainTexture); // add this
ProfileSkeleton.AnimationState.SetAnimation(0, "animation", true);

If that doesn't work, can you describe what you mean by "seems to not work"? What happens exactly? And are any errors logged?

No, it doesnt work neither.
I just said "seems" cuz i could be doing something wrong, but was exaclty as you did. And I have no errors at all.

The flow is:
1- I open the panel which shows me the first "client" with its animation. That first time loads skeleton and animation with no problem.
2- The panel has buttons to load previous/next client, after I click one of those it runs the same code to load the next client. But it does not show skeleton.

If I go the the skeleton in the hierarchy it has the next skeleton loaded. So the thing is just that it does not show up!

The only workaroung I found is to enable and disable the skeleton after running the skeleton code.

The whole panel is inside a maskUI cuz it also has unity animations (slides)

7 anos depois

this happened to me. I use unity 2021.3.33f1 spine version 3.8

I've fixed this.
private void SetSkeletionGraphic(SkeletonDataAsset asset)
{
_skeletonGraphic.skeletonDataAsset = asset;
_skeletonGraphic.Initialize(true);
_skeletonGraphic.enabled = false;
_skeletonGraphic.enabled = true;
}