Here are some code snippets of the useful parts.
1: Find all the BoundingBoxAttachment in a SkeletonUtility
2: Pass the Attachment to my own method to copy its location
void FindBoundingBoxThenProrcess()
{
var skeleton = m_skeletonUtility.Skeleton;
int slotCount = skeleton.Slots.Count;
var skin = skeleton.Skin;
if (skeleton.Skin == null)
skin = skeleton.Data.DefaultSkin;
for (int i = 0; i < slotCount; i++) {
var slot = skeleton.Slots.Items[i];
var slotAttachments = new List<Spine.Skin.SkinEntry>();
int slotIndex = skeleton.Data.FindSlot(slot.Data.Name).Index;
skin.GetAttachments(slotIndex, slotAttachments);
var boundingBoxes = new List<Spine.BoundingBoxAttachment>();
foreach (var skinEntry in slotAttachments) {
var boundingBoxAttachment = skinEntry.Attachment as Spine.BoundingBoxAttachment;
if (boundingBoxAttachment != null)
{
var boneTarget = m_skeletonUtility.boneComponents.FirstOrDefault( x => x.bone == slot.Bone);
var polygon = SkeletonUtility.AddBoundingBoxGameObject(boneTarget.bone.Skeleton, skin.Name, slot.Data.Name, boundingBoxAttachment.Name, boneTarget.transform);
polygon.gameObject.name = slot.Data.Name;
if(polygon.name.StartsWith("BUTT_"))
AddButton(polygon, polygon.name.Replace("BUTT_", ""));
else if(polygon.name.StartsWith("AREA_"))
AddArea(polygon, polygon.name.Replace("AREA_", ""));
}
}
}
}