protected void SafeSubscribe(Spine.TrackEntry trackEntry, AnimationEventTypes eventsToWaitFor) { if (trackEntry == null) { // Break immediately if trackEntry is null. Debug.LogWarning("TrackEntry was null. Coroutine will continue immediately."); m_WasFired = true; } else { if ((eventsToWaitFor & AnimationEventTypes.Start) != 0) { trackEntry.Start += HandleComplete; } if ((eventsToWaitFor & AnimationEventTypes.Interrupt) != 0) { trackEntry.Interrupt += HandleComplete; } if ((eventsToWaitFor & AnimationEventTypes.End) != 0) { trackEntry.End += HandleComplete; } if ((eventsToWaitFor & AnimationEventTypes.Dispose) != 0) { trackEntry.Dispose += HandleComplete; } if ((eventsToWaitFor & AnimationEventTypes.Complete) != 0) { trackEntry.Complete += HandleComplete; } } }
/// <summary> /// One optimization high-frequency YieldInstruction returns is to cache instances to minimize GC pressure. /// Use NowWaitFor to reuse the same instance of WaitForSpineAnimationComplete.</summary> public WaitForSpineAnimation NowWaitFor(Spine.TrackEntry trackEntry, AnimationEventTypes eventsToWaitFor) { SafeSubscribe(trackEntry, eventsToWaitFor); return(this); }
public WaitForSpineAnimation(Spine.TrackEntry trackEntry, AnimationEventTypes eventsToWaitFor) { SafeSubscribe(trackEntry, eventsToWaitFor); }