void OnApplicationFocus(bool hasFocus) { if (Application.isEditor) { return; } if (hasFocus) { using (WindowProvider.of(GlobalContext.context).getScope()) { AnalyticsManager.foucsTime = DateTime.UtcNow.ToString(); } } else { using (WindowProvider.of(GlobalContext.context).getScope()) { if (AnalyticsManager.foucsTime.isNotEmpty()) { AnalyticsManager.AnalyticsActiveTime( (DateTime.UtcNow - DateTime.Parse(AnalyticsManager.foucsTime)).Milliseconds); AnalyticsManager.foucsTime = null; } } } }
void OnApplicationQuit() { if (Application.isEditor) { return; } using (WindowProvider.of(GlobalContext.context).getScope()) { if (AnalyticsManager.foucsTime.isNotEmpty()) { AnalyticsManager.AnalyticsActiveTime((DateTime.UtcNow - DateTime.Parse(AnalyticsManager.foucsTime)) .Milliseconds); } } }