[csharp] Fix recursion in clearTracks.

Issue: https://github.com/EsotericSoftware/spine-runtimes/issues/805
based on f6cf88103c and 7dbf7c5268
This commit is contained in:
John 2016-12-15 05:58:49 +08:00 committed by GitHub
parent d2eebdf81f
commit dc8f89fd65

View File

@ -343,12 +343,13 @@ namespace Spine {
/// It may be desired to use <see cref="AnimationState.SetEmptyAnimations(float)"/> to mix the skeletons back to the setup pose, /// It may be desired to use <see cref="AnimationState.SetEmptyAnimations(float)"/> to mix the skeletons back to the setup pose,
/// rather than leaving them in their previous pose.</summary> /// rather than leaving them in their previous pose.</summary>
public void ClearTracks () { public void ClearTracks () {
bool oldDrainDisabled = queue.drainDisabled;
queue.drainDisabled = true; queue.drainDisabled = true;
for (int i = 0, n = tracks.Count; i < n; i++) { for (int i = 0, n = tracks.Count; i < n; i++) {
ClearTrack(i); ClearTrack(i);
} }
tracks.Clear(); tracks.Clear();
queue.drainDisabled = false; queue.drainDisabled = oldDrainDisabled;
queue.Drain(); queue.Drain();
} }
@ -510,12 +511,13 @@ namespace Spine {
/// <summary> /// <summary>
/// Sets an empty animation for every track, discarding any queued animations, and mixes to it over the specified mix duration.</summary> /// Sets an empty animation for every track, discarding any queued animations, and mixes to it over the specified mix duration.</summary>
public void SetEmptyAnimations (float mixDuration) { public void SetEmptyAnimations (float mixDuration) {
bool oldDrainDisabled = queue.drainDisabled;
queue.drainDisabled = true; queue.drainDisabled = true;
for (int i = 0, n = tracks.Count; i < n; i++) { for (int i = 0, n = tracks.Count; i < n; i++) {
TrackEntry current = tracks.Items[i]; TrackEntry current = tracks.Items[i];
if (current != null) SetEmptyAnimation(i, mixDuration); if (current != null) SetEmptyAnimation(i, mixDuration);
} }
queue.drainDisabled = false; queue.drainDisabled = oldDrainDisabled;
queue.Drain(); queue.Drain();
} }