geddski

I've looked all over in the docs for how to do this. I can get an attachment by name just fine, but don't see a way to hide it programmatically (Widget runtime).
geddski
  • Bài viết: 23

Mario

Let me take a step back and quickly outline how the skeleton hierarchy works. A skeleton is composed of one or more bones. A bone may have zero or more bone children. A bone may also have zero or more slots. Slots are locations in a skeleton to which attachments can be attached and thus made visible. A slot can only have a single attachment attached at a time.

So, to make an attachment invisible, you have to find the slot it is attached to, and then set the attachment on the slot to null. Assuming you know the slot the attachment is attached to, it's as simple as:
skeleton.findSlot("slotName").setAttachment(null);
Note that calling skeleton.setToSetupPose, skeleton.setSlotsToSetupPose, skeleton.setSkin as well as having attachment timelines may attach the attachment to the slot again.
Hình đại diện của thành viên
Mario

Mario
  • Bài viết: 2360

geddski

Ahhh that's how! Got it. Thank you!
geddski
  • Bài viết: 23

nicmar

For someone having problems with this in Unity, it should be like this. Maybe the API changed since 2.5 years :)
skeleton.SetAttachment("slotName",null);
Using Spine to make SpaceChef - The Taste of Trouble. A humoristic open world space western, featuring a chef with nothing to loose, after he loses everything.. ;) Follow our work on Twitter @BlueGooGames.
Hình đại diện của thành viên
nicmar
  • Bài viết: 55

Harald

Actually the above code is still valid (your line is a shortcut), although the spine-csharp (and thus spine-unity) API looks a little bit different than the other runtimes, as it uses properties instead of setter methods. And an uppercase first letter, as is the convention there:
skeletonRenderer.skeleton.FindSlot("name").Attachment = attachment;
Please also consider having a look at the Spine Examples directory before searching the forum, such basics are all covered there with lots of example code to check out.
Hình đại diện của thành viên
Harald

Harri
  • Bài viết: 2103


Quay về Runtimes