Ok, makes sense! So I've changed this:
TrackEntry trackEntry = _spineAnimationState.SetAnimation(0, animation, false);
trackEntry.Interrupt += OnChangeActiveEquipmentAnimationInterrupt;
trackEntry.Complete += OnChangeActiveEquipmentAnimationComplete;
void OnChangeActiveEquipmentAnimationInterrupt(TrackEntry trackEntry) {
trackEntry.Interrupt -= OnChangeActiveEquipmentAnimationInterrupt;
trackEntry.Complete -= OnChangeActiveEquipmentAnimationComplete;
UpdateSkin(_activeEquipment);
}
void OnChangeActiveEquipmentAnimationComplete(TrackEntry trackEntry) {
if (trackEntry != null) {
trackEntry.Interrupt -= OnChangeActiveEquipmentAnimationInterrupt;
trackEntry.Complete -= OnChangeActiveEquipmentAnimationComplete;
}
UpdateSkin(_activeEquipment);
AddIdleAnimationToQueue(_activeEquipment);
}
to this:
TrackEntry trackEntry = _spineAnimationState.SetAnimation(0, animation, false);
trackEntry.End += OnChangeActiveEquipmentAnimationEnd;
void OnChangeActiveEquipmentAnimationEnd(TrackEntry trackEntry) {
if (trackEntry != null) { trackEntry.End -= OnChangeActiveEquipmentAnimationEnd; }
UpdateSkin(_activeEquipment);
if (_spineAnimationState.GetCurrent(0) == null) { AddIdleAnimationToQueue(_activeEquipment); }
}
Can you see any issue with the logic? Basically before I was saying if the track was interrupted (another animation was set) don't play idle. Not I'm just checking to see if there's anything currently playing instead.
Edit: It appears End doesn't get called immediately on interrupt? Additionally interrupt seems to now being called almost immediately. How strange.
Edit 2: Ok, I see that End isn't actually called when an animation completes. Makes sense! I think I've figured it out, though I was closer with my original code.