From 659e043f1b260484877aeb021f3128485c85bdd2 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 721d2ab3b..e842d4835 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 @@ -171,8 +171,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.WorldX, bone.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 6e0817616..b33568de5 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 @@ -149,8 +149,9 @@ namespace Spine.Unity { followXYPosition ? bone.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.WorldX * scale + offset.x, bone.WorldY * scale + offset.y, 0f)); if (!followZPosition) targetWorldPosition.z = thisTransform.position.z;