[unity] Fixed broken Skeleton baking on 4.3 branch. Closes #3001.

This commit is contained in:
Harald Csaszar 2026-01-07 18:00:01 +01:00
parent d050ae6682
commit 5ab48156b4
2 changed files with 17 additions and 26 deletions

View File

@ -473,51 +473,43 @@ namespace Spine.Unity.Editor {
}
#region Attachment Baking
static Bone DummyBone;
static Skeleton DummySkeleton;
static Slot DummySlot;
internal static Bone GetDummyBone () {
if (DummyBone != null)
return DummyBone;
internal static Skeleton GetDummySkeleton () {
if (DummySkeleton != null)
return DummySkeleton;
SkeletonData skelData = new SkeletonData();
BoneData data = new BoneData(0, "temp", null) {
BoneData boneData = new BoneData(0, "temp", null) {
Length = 100
};
var setup = data.GetSetupPose();
var setup = boneData.GetSetupPose();
setup.ScaleX = setup.ScaleY = 1;
skelData.Bones.Add(data);
skelData.Bones.Add(boneData);
Skeleton skeleton = new Skeleton(skelData);
SlotData slotData = new SlotData(0, "temp", boneData);
skelData.Slots.Add(slotData);
Bone bone = new Bone(data, null);
bone.AppliedPose.UpdateWorldTransform(skeleton);
DummySkeleton = new Skeleton(skelData);
DummySkeleton.UpdateWorldTransform(Physics.Update);
DummyBone = bone;
return DummyBone;
}
internal static Skeleton GetDummySkeleton () {
SkeletonData skelData = new SkeletonData();
return new Skeleton(skelData);
return DummySkeleton;
}
internal static Slot GetDummySlot () {
if (DummySlot != null)
return DummySlot;
Bone bone = GetDummyBone();
Skeleton skeleton = GetDummySkeleton();
SlotData data = new SlotData(0, "temp", bone.Data);
Slot slot = new Slot(data, skeleton);
DummySlot = slot;
DummySlot = skeleton.Slots.Items[0];
return DummySlot;
}
internal static Mesh ExtractRegionAttachment (string name, RegionAttachment attachment, Mesh mesh = null, bool centered = true) {
Slot slot = GetDummySlot();
Skeleton skeleton = GetDummySkeleton();
Slot slot = skeleton.Slots.Items[0];
Bone bone = slot.Bone;
if (centered) {
@ -525,7 +517,6 @@ namespace Spine.Unity.Editor {
bone.Pose.Y = -attachment.Y;
}
Skeleton skeleton = GetDummySkeleton();
bone.AppliedPose.UpdateWorldTransform(skeleton);
float[] floatVerts = new float[8];
@ -559,8 +550,8 @@ namespace Spine.Unity.Editor {
}
internal static Mesh ExtractMeshAttachment (string name, MeshAttachment attachment, Mesh mesh = null) {
Slot slot = GetDummySlot();
Skeleton skeleton = GetDummySkeleton();
Slot slot = skeleton.Slots.Items[0];
slot.Bone.Pose.X = 0;
slot.Bone.Pose.Y = 0;

View File

@ -2,7 +2,7 @@
"name": "com.esotericsoftware.spine.spine-unity",
"displayName": "spine-unity Runtime",
"description": "This plugin provides the spine-unity runtime core and examples. Spine Examples can be installed via the Samples tab.",
"version": "4.3.34",
"version": "4.3.35",
"unity": "2018.3",
"author": {
"name": "Esoteric Software",