Пример #1
0
        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;
                    }
                }
            }
        }
Пример #2
0
        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);
                }
            }
        }