[unity] Fixed SkeletonUtilityBone follow-hierarchy producing wrong result with TransformConstraints. Closes #3035.

This commit is contained in:
Harald Csaszar 2026-02-26 12:33:28 +01:00
parent 945be36fea
commit b1cdc2db29
3 changed files with 16 additions and 10 deletions

View File

@ -204,8 +204,8 @@ namespace Spine.Unity {
UpdateLocal(skeletonGraphic); UpdateLocal(skeletonGraphic);
UpdateWorld(skeletonGraphic); UpdateWorld(skeletonGraphic);
UpdateComplete(skeletonGraphic); UpdateComplete(skeletonGraphic);
} }
} }
[HideInInspector] public SkeletonRenderer skeletonRenderer; [HideInInspector] public SkeletonRenderer skeletonRenderer;
[HideInInspector] public SkeletonGraphic skeletonGraphic; [HideInInspector] public SkeletonGraphic skeletonGraphic;
@ -362,16 +362,21 @@ namespace Spine.Unity {
if (skeleton == null) return; if (skeleton == null) return;
if (boneRoot != null) { if (boneRoot != null) {
List<object> constraintTargets = new List<object>(); List<Bone> constrainedBones = new List<Bone>();
ExposedList<IConstraint> constraints = skeleton.Constraints; ExposedList<IConstraint> constraints = skeleton.Constraints;
for (int i = 0, n = constraints.Count; i < n; i++) { for (int i = 0, n = constraints.Count; i < n; i++) {
IConstraint constraint = constraints.Items[i]; IConstraint constraint = constraints.Items[i];
ExposedList<BonePose> bones = null;
if (constraint is IkConstraint) if (constraint is IkConstraint)
constraintTargets.Add(((IkConstraint)constraint).Bones); bones = ((IkConstraint)constraint).Bones;
else if (constraint is TransformConstraint) else if (constraint is TransformConstraint)
constraintTargets.Add(((TransformConstraint)constraint).Bones); bones = ((TransformConstraint)constraint).Bones;
else if (constraint is PathConstraint) else if (constraint is PathConstraint)
constraintTargets.Add(((PathConstraint)constraint).Bones); bones = ((PathConstraint)constraint).Bones;
if (bones != null) {
for (int j = 0, m = bones.Count; j < m; j++)
constrainedBones.Add(bones.Items[j].bone);
}
} }
List<SkeletonUtilityBone> boneComponents = this.boneComponents; List<SkeletonUtilityBone> boneComponents = this.boneComponents;
@ -382,7 +387,7 @@ namespace Spine.Unity {
if (b.bone == null) continue; if (b.bone == null) continue;
} }
hasOverrideBones |= (b.mode == SkeletonUtilityBone.Mode.Override); hasOverrideBones |= (b.mode == SkeletonUtilityBone.Mode.Override);
hasConstraintTargetBones |= constraintTargets.Contains(b.bone); hasConstraintTargetBones |= constrainedBones.Contains(b.bone);
} }
needToReprocessBones = false; needToReprocessBones = false;

View File

@ -54,7 +54,7 @@ namespace Spine.Unity {
Complete Complete
} }
#region Inspector #region Inspector
/// <summary>If a bone isn't set, boneName is used to find the bone.</summary> /// <summary>If a bone isn't set, boneName is used to find the bone.</summary>
public string boneName; public string boneName;
public Transform parentReference; public Transform parentReference;
@ -62,7 +62,7 @@ namespace Spine.Unity {
public bool position, rotation, scale, zPosition = true; public bool position, rotation, scale, zPosition = true;
[Range(0f, 1f)] [Range(0f, 1f)]
public float overrideAlpha = 1; public float overrideAlpha = 1;
#endregion #endregion
public SkeletonUtility hierarchy; public SkeletonUtility hierarchy;
[System.NonSerialized] public Bone bone; [System.NonSerialized] public Bone bone;
@ -159,6 +159,7 @@ namespace Spine.Unity {
case UpdatePhase.World: case UpdatePhase.World:
case UpdatePhase.Complete: case UpdatePhase.Complete:
var appliedPose = bone.AppliedPose; var appliedPose = bone.AppliedPose;
appliedPose.ValidateLocalTransform(skeleton);
if (position) if (position)
thisTransform.localPosition = new Vector3(appliedPose.X * positionScale, appliedPose.Y * positionScale, thisTransform.localPosition = new Vector3(appliedPose.X * positionScale, appliedPose.Y * positionScale,
zPosition ? 0 : thisTransform.localPosition.z); zPosition ? 0 : thisTransform.localPosition.z);

View File

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