12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- namespace KairoEngine.Core
- {
- public class Cronometer
- {
-
- private float startTime;
- private float stopTime;
- private float totalTime;
- private bool running = false;
- public Cronometer()
- {
- startTime = Time.realtimeSinceStartup;
- running = true;
- }
- public void Start()
- {
- if(!running)
- {
- running = true;
- startTime = Time.realtimeSinceStartup;
- }
- }
- public Cronometer Stop()
- {
- if(running)
- {
- stopTime = Time.realtimeSinceStartup;
- totalTime += stopTime - startTime;
- running = false;
- startTime = 0f;
- stopTime = 0f;
- }
- return this;
- }
- public void Continue() => Start();
- public float value => totalTime;
- public string Print() => Utilities.TimeToString(value);
- }
- }
|