From 49999e417ee8e34fad323a73943f055fa6607df2 Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Thu, 7 Aug 2025 15:02:57 +0200 Subject: [PATCH] [unity] Fixed BoneFollower MissingReferenceException when skeleton is destroyed. Closes #2903. --- .../Runtime/spine-unity/Components/Following/BoneFollower.cs | 5 +++-- .../spine-unity/Components/Following/BoneFollowerGraphic.cs | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoneFollower.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoneFollower.cs index ebef9c3a0..c7b1b5d9c 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoneFollower.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoneFollower.cs @@ -199,8 +199,9 @@ namespace Spine.Unity { q.w = Mathf.Cos(halfRotation); thisTransform.localRotation = q; } - } else { - // For special cases: Use transform world properties if transform relationship is complicated + } else { // For special cases: Use transform world properties if transform relationship is complicated + if (!skeletonTransform) return; + Vector3 targetWorldPosition = skeletonTransform.TransformPoint(new Vector3(bone.AppliedPose.WorldX, bone.AppliedPose.WorldY, 0f)); if (!followZPosition) targetWorldPosition.z = thisTransform.position.z; if (!followXYPosition) { diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoneFollowerGraphic.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoneFollowerGraphic.cs index 448c12476..bd9d9572c 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoneFollowerGraphic.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoneFollowerGraphic.cs @@ -174,8 +174,9 @@ namespace Spine.Unity { followXYPosition ? bone.AppliedPose.WorldY * scale + offset.y : thisTransform.localPosition.y, followZPosition ? 0f : thisTransform.localPosition.z); if (followBoneRotation) thisTransform.localRotation = bone.GetQuaternion(); - } else { - // For special cases: Use transform world properties if transform relationship is complicated + } else { // For special cases: Use transform world properties if transform relationship is complicated + if (!skeletonTransform) return; + Vector3 targetWorldPosition = skeletonTransform.TransformPoint( new Vector3(bone.AppliedPose.WorldX * scale + offset.x, bone.AppliedPose.WorldY * scale + offset.y, 0f)); if (!followZPosition) targetWorldPosition.z = thisTransform.position.z;