- Home /
C# TimeSpan seems to not work properly when compiled into OSX executable?
The following works in the Editor in OSX but does not when I do a build:
TimeSpan TimeDiff = DateTime.UtcNow - m_nextGameTickTime; m_gameTicksToday += (int)(TimeDiff.TotalMilliseconds * m_timeTickMS);
It seems that once compiled, the executable is not capturing Milliseconds passed at the same granular level as the editor. On Debug.Log() it shows that it does not notice any Milliseconds have passed. It always reads 46. In the Editor, Debug.Log() shows the counter continually increasing as it should.
This is happening in a Mac/OSX build. The Editor is Mac OSX on the same machine as well.
Answer by kaarloew · Jan 24, 2019 at 07:34 AM
There is a difference in resolution of DateTime.UtcNow based on platform. But I am not completely sure if that is the issue in this case
The resolution of this property depends on the system timer, which depends on the underlying operating system. It tends to be between 0.5 and 15 milliseconds.
https://docs.microsoft.com/en-us/dotnet/api/system.datetime.utcnow?view=netframework-4.7.2
Your answer
Follow this Question
Related Questions
System.DateTime truncate Milliseconds 1 Answer
Problem: Unity3D iOS Pro 3.4 with OSX Lion and Xcode 4.1 1 Answer
Fullscreen on non-primary monitor in OS X 0 Answers
Building 64bit on OSX 1 Answer
Is there support for x86_64 only plugins 0 Answers