- Editado
How do you check if an attachment is enabled/disabled?
Specifically, how would I go about checking if the bounding box is currently disabled in the animation?
A bounding box doesn't have a disabled state. You probably want to check if a particular slot has the bounding box attachment set. You can get a Slot, eg with Skeleton findSlot
, and then check what attachment it has with Slot attachment
.
Note that an attachment can be in multiple slots in the same skeleton or in slots in other skeleton instances.
Yep, this works perfectly, many thanks!
var attachment = skeleton.FindSlot(slotName).Attachment;
var isEnabled = attachment != null;
Could you clarify something:
an attachment can be in multiple slots in the same skeleton or in slots in other skeleton instances.
I was under the impression that attachments can only be in one slot, and can not change parents during an animation.
Glad that helped!
IggyZuk escribióI was under the impression that attachments can only be in one slot, and can not change parents during an animation.
That is true in the editor, but at runtime you can use the API to do whatever you like. Grab any slot, set any attachment on it. Even if you don't do that, attachments are stateless and are shared across all skeleton instances. The class diagram illustrates that:
Runtime Architecture - Spine Runtimes Guide: Class diagram
Oh, I see! That's an important distinction between data objects and instance objects.
Please correct me if I'm wrong. It also looks like a slot can only ever have one attachment. In the Spine editor, you can see many attachments but only one can be active at a time. I guess this is an illusion made for a better user experience? And looking at the exported animation data file, there are details about all of the slot attachment changes. This would suggest that the animation engine is changing attachments.
Is the actual attachment data always stored in the default skin?
It's true that some of the view of the object graph in the editor is organized solely for the sanity of the UI, eg skin placeholders. At runtime a slot only has 1 attachment active at a time, same as in the editor. At runtime all attachments in the SkeletonData are in skins, though you can copy or create an attachment and set it on a slot directly, without it being in a skin. All attachments not in a skin in the editor are found in the default skin at runtime. Each attachment in a skin is stored for a specific slot and name, where that name corresponds to the skin placeholder name in the editor and may be different from the attachment's name. An AttachmentTimeline does set a slot's attachment and uses Skeleton setAttachment
to do so, which finds the attachment in the current skin and default skin.
Perfect! Thanks for the details, Nate