diff --git a/spine-csharp/src/AnimationState.cs b/spine-csharp/src/AnimationState.cs
index a4547c9df..fa70f3c0a 100644
--- a/spine-csharp/src/AnimationState.cs
+++ b/spine-csharp/src/AnimationState.cs
@@ -750,10 +750,11 @@ namespace Spine {
if (last == null) {
SetCurrent(trackIndex, entry, true);
queue.Drain();
+ if (delay < 0) delay = 0;
} else {
last.next = entry;
entry.previous = last;
- if (delay <= 0) delay += last.TrackComplete - entry.mixDuration;
+ if (delay <= 0) delay = Math.Max(delay + last.TrackComplete - entry.mixDuration, 0);
}
entry.delay = delay;
@@ -799,7 +800,7 @@ namespace Spine {
///
public TrackEntry AddEmptyAnimation (int trackIndex, float mixDuration, float delay) {
TrackEntry entry = AddAnimation(trackIndex, AnimationState.EmptyAnimation, false, delay);
- if (delay <= 0) entry.delay += entry.mixDuration - mixDuration;
+ if (delay <= 0) entry.delay = Math.Max(entry.delay + entry.mixDuration - mixDuration, 0);
entry.mixDuration = mixDuration;
entry.trackEnd = mixDuration;
return entry;
@@ -1049,17 +1050,24 @@ namespace Spine {
///
///
- /// Seconds to postpone playing the animation. When this track entry is the current track entry, Delay
- /// postpones incrementing the . When this track entry is queued, Delay is the time from
- /// the start of the previous animation to when this track entry will become the current track entry (ie when the previous
- /// track entry >= this track entry's Delay).
+ /// Seconds to postpone playing the animation. Must be >= 0. When this track entry is the current track entry,
+ /// Delay postpones incrementing the . When this track entry is queued,
+ /// Delay is the time from the start of the previous animation to when this track entry will become the current
+ /// track entry (ie when the previous track entry >= this track entry's
+ /// Delay).
///
/// affects the delay.
///
- /// When using with a delay <= 0, the delay
- /// is set using the mix duration from the . If is set afterward, the delay
- /// may need to be adjusted.
- public float Delay { get { return delay; } set { delay = value; } }
+ /// When passing delay <= 0 , this
+ /// delay is set using a mix duration from the . To change the
+ /// afterward, use so this delay is adjusted.
+ public float Delay {
+ get { return delay; }
+ set {
+ if (delay < 0) throw new ArgumentException("delay must be >= 0.", "delay");
+ delay = value;
+ }
+ }
///
/// Current time in seconds this track entry has been the current track entry. The track time determines
@@ -1261,7 +1269,12 @@ namespace Spine {
/// entry is looping, its next loop completion is used instead of its duration.
public void SetMixDuration (float mixDuration, float delay) {
this.mixDuration = mixDuration;
- if (previous != null && delay <= 0) delay += previous.TrackComplete - mixDuration;
+ if (delay <= 0) {
+ if (previous != null)
+ delay = Math.Max(delay + previous.TrackComplete - mixDuration, 0);
+ else
+ delay = 0;
+ }
this.delay = delay;
}
diff --git a/spine-csharp/src/package.json b/spine-csharp/src/package.json
index ced3135bc..d65fab540 100644
--- a/spine-csharp/src/package.json
+++ b/spine-csharp/src/package.json
@@ -2,7 +2,7 @@
"name": "com.esotericsoftware.spine.spine-csharp",
"displayName": "spine-csharp Runtime",
"description": "This plugin provides the spine-csharp core runtime.",
- "version": "4.2.36",
+ "version": "4.3.2",
"unity": "2018.3",
"author": {
"name": "Esoteric Software",