namespace LanLib.UpdateManager.Jobs { /// /// Struct for accessing properties from within jobs or other multithreaded code. /// /// /// All properties are available from Burst-compilable jobs. /// public struct UpdateJobTime { /// Cached value for from current running frame public static float time => InstanceRef.Time; /// Cached value for from current running frame public static float deltaTime => InstanceRef.DeltaTime; /// Cached value for from current running frame public static float smoothDeltaTime => InstanceRef.SmoothDeltaTime; /// Cached value for from current running frame public static float unscaledDeltaTime => InstanceRef.UnscaledDeltaTime; /// Cached value for from current running frame /// Contrary to , this property will return the same value if called twice during the same frame. public static float realtimeSinceStartup => InstanceRef.RealtimeSinceStartup; /// Cached value for from current running frame public static float timeSinceLevelLoad => InstanceRef.TimeSinceLevelLoad; /// Cached value for from current running frame public static int frameCount => InstanceRef.FrameCount; /// Cached value for from current running frame public float Time { get; private set; } /// Cached value for from current running frame public float DeltaTime { get; private set; } /// Cached value for from current running frame public float SmoothDeltaTime { get; private set; } /// Cached value for from current running frame public float UnscaledDeltaTime { get; private set; } /// Cached value for from current running frame /// Contrary to , this property will return the same value if called twice during the same frame. public float RealtimeSinceStartup { get; private set; } /// Cached value for from current running frame public float TimeSinceLevelLoad { get; private set; } /// Cached value for from current running frame public int FrameCount { get; private set; } public static UpdateJobTime Instance => InstanceRef; #if HAVE_BURST internal static readonly Unity.Burst.SharedStatic SharedInstance = Unity.Burst.SharedStatic.GetOrCreate(); internal static ref UpdateJobTime InstanceRef => ref SharedInstance.Data; #else internal static UpdateJobTime InstanceRef; #endif internal void Refresh() { Time = UnityEngine.Time.time; DeltaTime = UnityEngine.Time.deltaTime; SmoothDeltaTime = UnityEngine.Time.smoothDeltaTime; UnscaledDeltaTime = UnityEngine.Time.unscaledDeltaTime; RealtimeSinceStartup = UnityEngine.Time.realtimeSinceStartup; TimeSinceLevelLoad = UnityEngine.Time.timeSinceLevelLoad; FrameCount = UnityEngine.Time.frameCount; } } }