• Editor
  • Change Skeleton Data asset @ runtime - Unity / 2D toolkit

Hi,
Im Using spine for unity. i'm changing skeleton data asset for load different character. once it changed the data asset i'm calling
Character.state.AddAnimation(0, "Idle", true,0);
for change the animation. but above method is not working.. Do u have any idea for that issue ?

public void ChangeDataAsset(SkeletonDataAsset skeleton)
{
Character.skeletonDataAsset = skeleton;
Character.state.AddAnimation(0, "Idle", true,0)


}[/color]

Cheers
Praveee...

Related Discussions
...

You can use SetAnimation instead of AddAnimation.

Yeah, tried but no luck 🙁 anyway thanks for your reply.

Oh wait. You're changing the skeletonDatAsset. Why?

You could have two child GameObjects that have two different skeleton data.
Or I guess if you really have to do it this way, you can change the skeletonData,
call Character.Clear() then
Character.Initialize().
Then call SetAnimation. Not sure if that will work very well.

hey Pharan, I'm changing the skeletonDataAsset coz i wanna change character's costumes when i want. Is there a better way to doing it without changing the skeletonDataAsset ?
I tried Character.Clear() and Character.Initialize(). Yeah its working perfectly now 🙂. Thank you very much for your help. 🙂
cheers !
praveee ...

You can learn how to use Skins. Swappable costumes is one of the things it's supposed to be for.

The goblins project has an example. Images are swapped between male and female goblins in the same skeleton. But you can also just swap a few and not all images.

I've never used it on an actual character before so I don't have much advice regarding how to use it.

Best of luck on your game!

Pharan, I checked the goblins sample project.yes it seems to be changing skins are easier then changing data-asset. and also it has methods to switch on / off attachments too. thanks for your advice
cheers !
praveee ...