EDIT: Oh, I see the misleading thing. There's a key icon next to the slot's visibility dot. One could easily assume that the key was for the slot's visibility dot and then wonder why it doesn't key the thing right next to it. I imagine this should be resolved when the slot image chooser (https://trello.com/c/3lKrve5E) finally gets implemented if the key icon gets moved to that popup instead of beside the slot's visibility dot.
You didn't need the event handler to set the attachment to null.
You can key the attachment of a slot to be none/empty/null by just turning the attachment's visibility dot off and then keying that. That's basically an attachment = null
key. This is has been animatable through the AttachmentTimeline since the beginning. And it's equivalent to hiding the slot.
I'm curious as to what case this doesn't solve though. Why isn't it an option when code is involved?
Even if the slot was empty, you could still key it as null at certain points. It's just that it wouldn't reset properly if you told the skeleton to setSlotsToSetupPose
, unless you added the weapon by modifying the setup pose/SkeletonData.
Was the slot generated at runtime too?
I would've used skins for this though, for its reliable resetting behavior and sensibility when animating and coding.
In fact, I think this is one of the basic reasons for a mix-and-match skin system that's previewable in the editor. Games with equips are common enough. The attachment dictionary behind skins at runtime already works well for implementing swappable equips and things. It's just that it's not overtly supported by the editor. Attachment alignments are best done in the editor anyway.
Either way, the "attachment = null" key stays relevant. XD