I love you guys.
_twistedhorror

- Inscrit 4 mai 2024
It would be nice if it was possible to add arbitrary tags to different objects in a Spine Scene. I am doing code work and in order to find specific things in the Skeleton I need to know the Attachment or Bone name but these often change throughout development.
The solution at present is to enforce a naming convention to Bones/Attachments with a prefix "Button" or "Collider"
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 locationvoid 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_", "")); } } } }
For context, I do "approximate" the location in the Editor before the game is run but this is 100% not needed. I do it to remind myself where things should be.
I'm working with an artist to make a silly airport game. I wanted the Artist to be able to decide where text should go without dealing with Unity so, we compromised and I got the Artist to make a BoundingBox within Spine for the location of the text.
The Unity script I made will then search for all bounding box and try to make its size and position with a UI object and match them up. Pretty nifty, saves me a lot of time. It works changing resolution too, iterate all the objects and do it again.
I lurk and use the forum so much and made an account mostly to say, thank you. Between using my own janky PSD exporter that was originally from the repo version, having the built in PSD. You have saved me hours of time per day in my workflow. The [skins], [ignore], [merge] and the other tags I regularly use in the PSD just work. Please give this man a god dam round of applause! You have deprecated my janky Photoshop code.
100% recommend this update.