Fixed some timer bugs

Timer now has a mode for unscaled time
FIXED: Countdown now resets properly
This commit is contained in:
Gerard Gascón 2021-06-12 10:36:38 +02:00 committed by GitHub
parent 750d7f6b88
commit a4c26426e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 53 additions and 9 deletions

View file

@ -6,7 +6,14 @@ using TMPro;
namespace SimpleTools.Timer{
public static class TimerUtility {
public static Timer SetupTimer(this TMP_Text container, TimerType timerType, float countdownTime = 60f){
/// <summary>
/// Setup the timer
/// </summary>
/// <param name="container">TMPro object that will contain the timer</param>
/// <param name="timerType">What type of timer will it be (Countdown, Stopwatch, Clock)</param>
/// <param name="countdownTime">The time that will have in case it is a countdown timer</param>
/// <returns></returns>
public static Timer SetupTimer(this TMP_Text container, TimerType timerType, TimerUpdate timerUpdate, float countdownTime = 60f){
Timer t = container.gameObject.AddComponent<Timer>();
float elapsedTime = 0f;
string text = string.Empty;
@ -21,7 +28,7 @@ namespace SimpleTools.Timer{
text = DateTime.Now.ToString("HH:mm:ss");
break;
}
t.Setup(elapsedTime, true, timePlaying, container, timerType, text);
t.Setup(elapsedTime, true, timePlaying, container, timerType, timerUpdate, text);
return t;
}