You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
2 years ago | |
|---|---|---|
| .. | ||
| Android | 2 years ago | |
| Demo | 2 years ago | |
| DevToDevOSX.bundle | 2 years ago | |
| Editor | 2 years ago | |
| Metro | 2 years ago | |
| Standalone | 2 years ago | |
| UDP | 2 years ago | |
| UnbiasedTime | 2 years ago | |
| UnityPurchasing | 2 years ago | |
| WebGL | 2 years ago | |
| iOS | 2 years ago | |
| Android.meta | 2 years ago | |
| Demo.meta | 2 years ago | |
| DevToDevOSX.bundle.meta | 2 years ago | |
| Editor.meta | 2 years ago | |
| Metro.meta | 2 years ago | |
| Standalone.meta | 2 years ago | |
| UDP.meta | 2 years ago | |
| UnbiasedTime.meta | 2 years ago | |
| UnityPurchasing.meta | 2 years ago | |
| WebGL.meta | 2 years ago | |
| iOS.meta | 2 years ago | |
| readme.txt | 2 years ago | |
| readme.txt.meta | 2 years ago | |
readme.txt
# Time-cheat prevention
iOS native plugin to prevent cheating by changing phone time in settings.
Works in offline mode.
Plugin have simple API which main method is Now(). It returns current timestamp
that is initialized at first app launch and increment monotonically regardless of
time changes in device settings.
### Usage
1. Plugins/iOS folder contains native static lib for iOS: `libUnbiasedTime.a`.
It should be included automatically in the generated Xcode project.
2. UnbiasedTime.cs is a wrapper script for native lib. It is a singleton class
and creates empty GameObject on first access to `UnbiasedTime.Instance`.
3. Call `UnbiasedTime.Instance.Now()` to get estimated real timestamp. Use it for
time span calculations, but be aware that it have 1 second precision.
### Sample project
Simple demo included. It have two timers: one naive using `DateTime.Now` and the other
is using `UnbiasedTime.Instance.Now()`. Timers are implemented by remembering timestamp of timespan end in PlayerPrefs
so they keep counting even if app is backgrounded or closed. Launch it on your mobile device, tap +60 seconds several times, then go to
settings and increment current device time by few minutes. One timer will advance forward, while the other will keep
it's speed unchanged measuring real time.
### Caution
It is advised to use timestamp server to get real world time and fallback to `UnbiasedTime.Instance.Now()` only
when offline.