diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Threading/SkeletonUpdateSystem.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Threading/SkeletonUpdateSystem.cs index 0b32997c9..a158ed8c4 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Threading/SkeletonUpdateSystem.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Threading/SkeletonUpdateSystem.cs @@ -106,10 +106,18 @@ namespace Spine.Unity { } public static int SkeletonSortComparer (ISkeletonRenderer first, ISkeletonRenderer second) { - return first.Skeleton.Data.GetHashCode() - second.Skeleton.Data.GetHashCode(); + Skeleton firstSkeleton = first.Skeleton; + Skeleton secondSkeleton = second.Skeleton; + if (firstSkeleton == null) return secondSkeleton == null ? 0 : -1; + else if (secondSkeleton == null) return 1; + else return firstSkeleton.Data.GetHashCode() - secondSkeleton.Data.GetHashCode(); } public static int SkeletonSortComparer (SkeletonAnimationBase first, SkeletonAnimationBase second) { - return first.Skeleton.Data.GetHashCode() - second.Skeleton.Data.GetHashCode(); + Skeleton firstSkeleton = first.Skeleton; + Skeleton secondSkeleton = second.Skeleton; + if (firstSkeleton == null) return secondSkeleton == null ? 0 : -1; + else if (secondSkeleton == null) return 1; + else return firstSkeleton.Data.GetHashCode() - secondSkeleton.Data.GetHashCode(); } public static readonly Comparison SkeletonRendererComparer = SkeletonSortComparer; public static readonly Comparison SkeletonAnimationComparer = SkeletonSortComparer;