Harald
The issue happened because I called gameObject.SetActive(false) directly inside a Spine animation event callback. In my case, the Spine character has a child Skeleton GameObject, and I attempted to hide that child object inside OnSpineEvent.
Minimal code that caused the error:
void OnSpineEvent(TrackEntry entry, Spine.Event e) {
if (e.Data.Name == "hide_event") {
// Hiding a child Skeleton GameObject during the callback
childSkeletonGameObject.SetActive(false);
}
}
(The fix is simply using a boolean flag here and deferring the SetActive(false) to Unity's Update() method.)
I found the culprit by adding a stack trace check inside SkeletonUpdateSystem.UnregisterFromUpdate:
public void UnregisterFromUpdate (UpdateTiming updateTiming, SkeletonAnimationBase skeletonAnimation) {
// ... [Original Spine Code] ...
skeletonAnimations.Remove(skeletonAnimation);
skeletonAnimation.IsUpdatedExternally = false;
// ======== [My Debug Trap] ========
var trace = UnityEngine.StackTraceUtility.ExtractStackTrace();
if (trace.Contains("UpdateAsync") || trace.Contains("UpdateInternalSplit") || trace.Contains("UpdateExternal")) {
UnityEngine.Debug.LogError($"GameObject '{skeletonAnimation.gameObject.name}' removed itself mid-update, causing the list to crash!\nStackTrace:\n{trace}");
}
// =================================
}
Apologies, this turned out to be an issue in my own code. Thanks for your help!