37 lines
927 B
C#
37 lines
927 B
C#
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);
|
|
}
|
|
}
|
|
}
|
|
} |