diff --git a/spine-unity/Assets/spine-unity/Modules/BoundingBoxFollower/BoundingBoxFollower.cs b/spine-unity/Assets/spine-unity/Modules/BoundingBoxFollower/BoundingBoxFollower.cs index 9a71ae8dc..2e5820c12 100644 --- a/spine-unity/Assets/spine-unity/Modules/BoundingBoxFollower/BoundingBoxFollower.cs +++ b/spine-unity/Assets/spine-unity/Modules/BoundingBoxFollower/BoundingBoxFollower.cs @@ -160,25 +160,25 @@ namespace Spine.Unity { } void DisposeColliders () { - #if UNITY_EDITOR var colliders = GetComponents(); if (colliders.Length == 0) return; - if (Application.isPlaying) { - foreach (var c in colliders) { - if (c != null) - Destroy(c); + if (Application.isEditor) { + if (Application.isPlaying) { + foreach (var c in colliders) { + if (c != null) + Destroy(c); + } + } else { + foreach (var c in colliders) + if (c != null) + DestroyImmediate(c); } } else { - foreach (var c in colliders) - if (c != null) - DestroyImmediate(c); + foreach (PolygonCollider2D c in colliders) + if (c != null) + Destroy(c); } - #else - foreach (PolygonCollider2D c in colliderTable.Values) - if (c != null) - Destroy(c); - #endif slot = null; currentAttachment = null;