The thing is that we are using keyed skin attachments in the animations, so just assigning region attachments to those slots does not make sense. Besides there is a runtime error if I try to assign a region attachment programmatically to a slot that has a skin attachment assigned in the UI.
skeleton.skeleton.setAttachment("hand2", "v_arm_hand__sword");
skeleton.skeleton.setToSetupPose();
results in:
ArgumentError: Attachment not found: v_arm_hand__sword, for slot: hand2
at spine::Skeleton/setAttachment()[C:\work\component\ngp\game_clients\slotmachines\qb2-DEV\legendsofcolosseum\src\spine\Skeleton.as:181]
at objects::SpinePOC()[C:\work\component\ngp\game_clients\slotmachines\qb2-DEV\legendsofcolosseum\src\objects\SpinePOC.as:101]
The setup pose attachments in the JSON looks like this:
// the "weapon" attachment is a skin attachment
"slots": [
...
{ "name": "hand2", "bone": "v_arm_hand", "attachment": "weapon" }
],
But I do not get a runtime error if I do like this:
skeleton.skeleton.setAttachment("hand2", "weapon");
skeleton.skeleton.setToSetupPose();
If I do the above for a skin created in the UI, nothing special happens (it looks the same as if I would not have made that setAttachment call, but the slot has content at least). But what does that line of code actually do? It reassigns the same skin attachment to the slot, but how to tell what region attachment should be linked to that skin attachment?
If I first set the skin to a UI created skin, do setToSetupPose and then apply a a programmatically created skin and do setToSetupPose and do the above setAttchment it renders the slot empty during the animation.
Is my way of creating a skin programmatically incorrect?
var skin1:Skin = new Skin("test");
var idHand2:int = skeleton.skeleton.findSlotIndex("hand2");
skin1.addAttachment(idHand2, "weapon", atlasLoader.newAttachment(null, AttachmentType.region, "v_arm_hand_club"));
skeletonData.addSkin(skin1);
skeleton.skeleton.skin = skin1;
skeleton.skeleton.setToSetupPose();
this has the same result:
var skin1:Skin = new Skin("test");
var idHand2:int = skeleton.skeleton.findSlotIndex("hand2");
skin1.addAttachment(idHand2, "weapon", atlasLoader.newAttachment(null, AttachmentType.region, "v_arm_hand_club"));
skeletonData.addSkin(skin1);
skeleton.skeleton.skin = skin1;
skeleton.skeleton.setToSetupPose();
// And the below lines should not be needed anyway, as the setting of the skin should do it
skeleton.skeleton.setAttachment("hand2", "weapon");
skeleton.skeleton.setToSetupPose();
Or is it in fact impossible to programmatically create a skin that attach different region attachment to slots with skin attachment? Because if it is not currently possible we have to try to use more slots with only region attachments instead. And I want to sort this before the graphics artist start to do too much work if he then is forced to redo it another way.
The reason we want to do it like this is that we have a character that can have 5 different races and 2 different genders and each slot uses several different keyed attachments and most of the slots also will equip different kinds of gear. That is why we need to be able to control it by code as not to be forced to create thousands of animations