Added Timer
New version featuring a timer
This commit is contained in:
parent
f7c4067db4
commit
750d7f6b88
14 changed files with 186 additions and 23 deletions
29
Tools/Timer/TimerUtility.cs
Normal file
29
Tools/Timer/TimerUtility.cs
Normal file
|
@ -0,0 +1,29 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using TMPro;
|
||||
|
||||
namespace SimpleTools.Timer{
|
||||
public static class TimerUtility {
|
||||
public static Timer SetupTimer(this TMP_Text container, TimerType timerType, float countdownTime = 60f){
|
||||
Timer t = container.gameObject.AddComponent<Timer>();
|
||||
float elapsedTime = 0f;
|
||||
string text = string.Empty;
|
||||
TimeSpan timePlaying = TimeSpan.Zero;
|
||||
switch (timerType){
|
||||
case TimerType.Countdown:
|
||||
elapsedTime = countdownTime;
|
||||
timePlaying = TimeSpan.FromSeconds(elapsedTime);
|
||||
text = timePlaying.ToString("m':'ss'.'ff");
|
||||
break;
|
||||
case TimerType.Clock:
|
||||
text = DateTime.Now.ToString("HH:mm:ss");
|
||||
break;
|
||||
}
|
||||
t.Setup(elapsedTime, true, timePlaying, container, timerType, text);
|
||||
|
||||
return t;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue