I'm still on 3.0.6, but looks the same in 3.0.7.
TNCounter.cs
var time = System.DateTime.UtcNow.Ticks * 0.0000001;
But there are 10,000 ticks per ms, so this should be:
var time = System.DateTime.UtcNow.Ticks * 0.0001;
Reference:
https://msdn.microsoft.com/en-us/library/system.timespan.tickspermillisecond(v=vs.110).aspxThis causes the counter to get the wrong value the first time it is used on the client after being sent from the server.
It was tricky to figure out since it doesn't happen if you are in the room when a packet gets sent with a Counter in it (because the packet is just forwarded directly), bit it will happen if it is one that was saved on the server since the server serialization causes this issue.
It's also nice to have a ToString for TNCounter (helped with debugging & looks nice in the TNObject Unity inspector):
public override string ToString() {
return string.Format("{0:f2} [{1},{2}] {3}/sec", value, min, max, rate*1000);
}
I also had to modify TNSerialier.WriteObject:
else if (obj is IBinarySerializable && (obj is Counter)==false)
Otherwise the Counter just gets serialized like IBinarySerializable instad of using the special efficient GetPrefix identifier (24). Somehow IBinarySerializable didn't work either, perhaps because I had the type fully qualified as TNet.Counter, not sure didn't investigate that further.
Now everything seems to be working nicely