First commit
This commit is contained in:
36
Runtime/TimeSince.cs
Normal file
36
Runtime/TimeSince.cs
Normal file
@ -0,0 +1,36 @@
|
||||
// https://garry.tv/timesince
|
||||
|
||||
//TimeSince ts;
|
||||
|
||||
//void Start()
|
||||
//{
|
||||
// ts = 0;
|
||||
//}
|
||||
|
||||
//void Update()
|
||||
//{
|
||||
// if (ts > 10)
|
||||
// {
|
||||
// DoSomethingAfterTenSeconds();
|
||||
// }
|
||||
//}
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace Agoxandr.Utils
|
||||
{
|
||||
public struct TimeSince
|
||||
{
|
||||
private float time;
|
||||
|
||||
public static implicit operator float(TimeSince ts)
|
||||
{
|
||||
return Time.time - ts.time;
|
||||
}
|
||||
|
||||
public static implicit operator TimeSince(float ts)
|
||||
{
|
||||
return new TimeSince { time = Time.time - ts };
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user