perf: NetworkTime.localTime inlined

This commit is contained in:
vis2k 2022-03-12 20:26:02 +08:00
parent 45e1afc812
commit 18170d16b8

View File

@ -1,4 +1,5 @@
using System;
using System.Runtime.CompilerServices;
using UnityEngine;
#if !UNITY_2020_3_OR_NEWER
using Stopwatch = System.Diagnostics.Stopwatch;
@ -26,7 +27,11 @@ public static class NetworkTime
/// <summary>Returns double precision clock time _in this system_, unaffected by the network.</summary>
#if UNITY_2020_3_OR_NEWER
public static double localTime => Time.timeAsDouble;
public static double localTime
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => Time.timeAsDouble;
}
#else
// need stopwatch for older Unity versions, but it's quite slow.
// CAREFUL: unlike Time.time, this is not a FRAME time.