mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
revert previous commit NetworkTime modifications. keep TimeAsDouble
This commit is contained in:
parent
70e972aeb5
commit
527dda561a
@ -6,7 +6,9 @@
|
|||||||
// some users may still be using that.
|
// some users may still be using that.
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
#if !UNITY_2020_3_OR_NEWER
|
||||||
using Stopwatch = System.Diagnostics.Stopwatch;
|
using Stopwatch = System.Diagnostics.Stopwatch;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Mirror
|
namespace Mirror
|
||||||
{
|
{
|
||||||
@ -23,15 +25,21 @@ public static class NetworkTime
|
|||||||
|
|
||||||
static ExponentialMovingAverage _rtt = new ExponentialMovingAverage(PingWindowSize);
|
static ExponentialMovingAverage _rtt = new ExponentialMovingAverage(PingWindowSize);
|
||||||
|
|
||||||
|
/// <summary>Returns double precision clock time _in this system_, unaffected by the network.</summary>
|
||||||
|
#if UNITY_2020_3_OR_NEWER
|
||||||
|
public static double localTime
|
||||||
|
{
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
get => Time.timeAsDouble;
|
||||||
|
}
|
||||||
|
#else
|
||||||
// need stopwatch for older Unity versions, but it's quite slow.
|
// need stopwatch for older Unity versions, but it's quite slow.
|
||||||
// CAREFUL: unlike Time.time, this is not a FRAME time.
|
// CAREFUL: unlike Time.time, this is not a FRAME time.
|
||||||
// it changes during the frame too.
|
// it changes during the frame too.
|
||||||
static readonly Stopwatch stopwatch = new Stopwatch();
|
static readonly Stopwatch stopwatch = new Stopwatch();
|
||||||
|
|
||||||
static NetworkTime() => stopwatch.Start();
|
static NetworkTime() => stopwatch.Start();
|
||||||
|
|
||||||
/// <summary>Returns double precision clock time _in this system_, unaffected by the network.</summary>
|
|
||||||
public static double localTime => stopwatch.Elapsed.TotalSeconds;
|
public static double localTime => stopwatch.Elapsed.TotalSeconds;
|
||||||
|
#endif
|
||||||
|
|
||||||
/// <summary>The time in seconds since the server started.</summary>
|
/// <summary>The time in seconds since the server started.</summary>
|
||||||
// via global NetworkClient snapshot interpolated timeline (if client).
|
// via global NetworkClient snapshot interpolated timeline (if client).
|
||||||
@ -69,7 +77,9 @@ public static void ResetStatics()
|
|||||||
PingWindowSize = 6;
|
PingWindowSize = 6;
|
||||||
lastPingTime = 0;
|
lastPingTime = 0;
|
||||||
_rtt = new ExponentialMovingAverage(PingWindowSize);
|
_rtt = new ExponentialMovingAverage(PingWindowSize);
|
||||||
|
#if !UNITY_2020_3_OR_NEWER
|
||||||
stopwatch.Restart();
|
stopwatch.Restart();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void UpdateClient()
|
internal static void UpdateClient()
|
||||||
|
Loading…
Reference in New Issue
Block a user