Skip to content

Commit 62afe1d

Browse files
committed
paused property
1 parent c45548e commit 62afe1d

2 files changed

Lines changed: 26 additions & 3 deletions

File tree

Lib/TSTimeDef.cs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ public class TSTimeDef
1111
public object onCompleteParams = null;
1212
public Action onComplete = null;
1313

14+
protected bool paused = false;
15+
16+
private float pausedTime;
1417

1518
public float Progress
1619
{
@@ -28,8 +31,28 @@ public float Progress
2831
startTime = now - value * duration;
2932
Update(now);
3033
}
31-
}
32-
34+
}
35+
36+
public bool Paused
37+
{
38+
get { return paused; }
39+
set
40+
{
41+
if (paused != value)
42+
{
43+
paused = value;
44+
if (paused)
45+
{
46+
pausedTime = Time.realtimeSinceStartup;
47+
}
48+
else
49+
{
50+
startTime = Time.realtimeSinceStartup - (pausedTime - startTime);
51+
}
52+
}
53+
}
54+
}
55+
3356
public TSTimeDef(float duration)
3457
{
3558
startTime = Time.realtimeSinceStartup;

TweenSharp.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public void Restart()
118118

119119
public override bool Update(float time)
120120
{
121-
if (startTime + delay < time)
121+
if (!paused && startTime + delay < time)
122122
{
123123
int len = propertyNames.Count;
124124
float timePassed;

0 commit comments

Comments
 (0)