Skip to content

Commit c7e9971

Browse files
committed
force all tweens to have a duration greater than 0.
1 parent 17c4157 commit c7e9971

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

Assets/Plugins/GoKit/GoTween.cs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,22 @@ public GoEaseType easeType
4444
/// </summary>
4545
public AnimationCurve easeCurve { get; set; }
4646

47-
/// <summary>
48-
/// initializes a new instance and sets up the details according to the config parameter
49-
/// </summary>
50-
public GoTween( object target, float duration, GoTweenConfig config, Action<AbstractGoTween> onComplete = null )
51-
{
52-
// default to removing on complete
53-
autoRemoveOnComplete = true;
47+
/// <summary>
48+
/// initializes a new instance and sets up the details according to the config parameter
49+
/// </summary>
50+
public GoTween( object target, float duration, GoTweenConfig config, Action<AbstractGoTween> onComplete = null )
51+
{
52+
// all tweens must be intialized to have a duration greater than zero. keep in mind that this will ensure
53+
// the tween occurs over two frames: the initialized value, and the final value. if you are looking for a
54+
// tween to reach the end of it's tween immediately, be sure to call complete() on it after creation.
55+
if( duration <= 0 )
56+
{
57+
duration = float.Epsilon;
58+
Debug.LogError( "tween duration must be greater than 0. coerced to float.Epsilon." );
59+
}
60+
61+
// default to removing on complete
62+
autoRemoveOnComplete = true;
5463

5564
// allow events by default
5665
allowEvents = true;

0 commit comments

Comments
 (0)