/// <summary> /// Stops the tween. /// </summary> /// <param name="stopBehavior">The behavior to use to handle the stop.</param> public void Stop(TweenStopBehavior stopBehavior) { if (state != TweenState.Stopped) { state = TweenState.Stopped; if (stopBehavior == TweenStopBehavior.Complete) { currentTime = duration; UpdateValue(); if (completionCallback != null) { completionCallback.Invoke(this); completionCallback = null; } if (continueWith != null) { continueWith.Start(); #if IS_UNITY TweenFactory.AddTween(continueWith); #else // TODO: Implement your own continueWith handling #endif continueWith = null; } } } }
public void Stop(TweenStopBehavior behavior) { switch (behavior) { case TweenStopBehavior.AsIs: State = TweenState.Stopped; break; case TweenStopBehavior.ForceComplete: _timer = _duration; break; default: throw new ArgumentOutOfRangeException(nameof(behavior), behavior, null); } }
/// <summary> /// Stops the tween. /// </summary> /// <param name="stopBehavior">The behavior to use to handle the stop.</param> public void Stop(TweenStopBehavior stopBehavior) { if (state != TweenState.Stopped) { state = TweenState.Stopped; if (stopBehavior == TweenStopBehavior.Complete) { currentTime = duration; UpdateValue(); if (completionCallback != null) { completionCallback.Invoke(this); completionCallback = null; } } } }
/// <summary> /// Remove a tween by key /// </summary> /// <param name="key">Key to remove</param> /// <param name="stopBehavior">Stop behavior</param> /// <returns>True if removed, false if not</returns> public static bool RemoveTweenKey(object key, TweenStopBehavior stopBehavior) { if (key == null) { return false; } bool foundOne = false; for (int i = tweens.Count - 1; i >= 0; i--) { ITween t = tweens[i]; if (key.Equals(t.Key)) { t.Stop(stopBehavior); tweens.RemoveAt(i); foundOne = true; } } return foundOne; }
/// <summary> /// Stops the tween. /// </summary> /// <param name="stopBehavior">The behavior to use to handle the stop.</param> public void Stop(TweenStopBehavior stopBehavior) { if (state != TweenState.Stopped) { state = TweenState.Stopped; if (stopBehavior == TweenStopBehavior.Complete) { currentTime = duration; UpdateValue(); if (completionCallback != null) { completionCallback.Invoke(this); completionCallback = null; } if (continueWith != null) { continueWith.Start(); TweenFactory.AddTween(continueWith); continueWith = null; } } } }
/// <summary> /// Remove a tween /// </summary> /// <param name="tween">Tween to remove</param> /// <param name="stopBehavior">Stop behavior</param> /// <returns>True if removed, false if not</returns> public static bool RemoveTween(ITween tween, TweenStopBehavior stopBehavior) { tween.Stop(stopBehavior); return tweens.Remove(tween); }