Search Unity

Monotone Crossplatform Clock

Discussion in 'Scripting' started by xmedeko, Apr 11, 2019.

  1. xmedeko

    xmedeko

    Joined:
    Jun 6, 2018
    Posts:
    23
    We need some monotone, reliable, cross platform clock with ms precision for working with external devices. So far, we have options:

    Time.fixedUnscaledTime
    - it's just a float, so we cannot trust the [ms] after about 5 hour, see https://gamedev.stackexchange.com/a/141811/126131

    Stopwatch
    - not sure it it's monotone an all platforms or it is uses just
    DateTime.UtcNow.Ticks
    . Note: UtcNow is not monotone, system time may be changed by the user or NTP sync, etc. See also https://forum.unity.com/threads/no-monotonic-clock-on-il2cpp.540207/

    Are there any other options? Or does
    Stopwatch
    use proper monotone clock, on which platforms?
     
    Last edited: Apr 11, 2019