1
This commit is contained in:
37
Packages/Runtime/Components/StopWatcher.cs
Normal file
37
Packages/Runtime/Components/StopWatcher.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace BITKit
|
||||
{
|
||||
public class StopWatcher : MonoBehaviour
|
||||
{
|
||||
[SerializeReference, SubclassSelector] public References timeFormat;
|
||||
public bool autoStart;
|
||||
public Provider output;
|
||||
bool started;
|
||||
DateTime dateTime = new();
|
||||
void Start()
|
||||
{
|
||||
if (autoStart)
|
||||
{
|
||||
started = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (started)
|
||||
{
|
||||
dateTime = dateTime.AddSeconds(Time.deltaTime);
|
||||
var timeStr = dateTime.ToString();
|
||||
if (timeFormat is not null)
|
||||
{
|
||||
timeStr = dateTime.ToString(timeFormat);
|
||||
}
|
||||
output.Set(timeStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user