Skip to content

Commit

Permalink
pause/resume for tweens
Browse files Browse the repository at this point in the history
  • Loading branch information
j-bbr committed Apr 17, 2017
1 parent 7daddf9 commit 915285f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
19 changes: 18 additions & 1 deletion Assets/Easing/Tween.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class Tween {
public const Action doNothing = null;
public TweenType type = TweenType.f;
public TweenRepeat repeat = TweenRepeat.Once;
public Coroutine animationRoutine;

public enum TweenType
{
Expand Down Expand Up @@ -153,7 +154,23 @@ public Tween(float seconds)
this.type = TweenType.delay;
}
#endregion


#region Animation
public void Play()
{
TweenManager.instance.PlayTween(this);
}
public void Stop()
{
if(animationRoutine != null)
TweenManager.instance.StopTween(animationRoutine);
}
public void Reset()
{
this.restTime = this.originalTime;
}
#endregion

#region Tween Value Setters
public Vector2 Vector2Value
{
Expand Down
4 changes: 3 additions & 1 deletion Assets/Easing/TweenManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ public sealed class TweenManager : UnitySingleton<TweenManager> {
/// <param name="t">Tween.</param>
public Coroutine PlayTween(Tween t)
{
return StartCoroutine(Animate(t));
var routine = StartCoroutine(Animate(t));
t.animationRoutine = routine;
return routine;
}
/// <summary>
/// Chains the tweens for sequential execution
Expand Down

0 comments on commit 915285f

Please sign in to comment.