Exemplo n.º 1
0
        IEnumerator Start()
        {
            _requestUrl = null;
            // Wait for additional init.
            yield return(null);

#if UNITY_EDITOR
            if (string.IsNullOrEmpty(_trackerID))
            {
                Debug.LogWarning("GA.TrackerID not defined");
            }
#endif
            if (!string.IsNullOrEmpty(_trackerID))
            {
                _requestUrl = string.Format(
                    AnalyticsUrl,
                    _trackerID,
                    DeviceHash,
                    Screen.width, Screen.height,
                    Application.bundleIdentifier,
                    Application.version
                    );
            }

            string url  = null;
            string data = null;

            while (true)
            {
                if (_requests.Count > 0)
                {
                    data = _requests.Dequeue();
                    // If tracking id defined and url inited.
                    if (!string.IsNullOrEmpty(_requestUrl))
                    {
                        url = string.Format("{0}{1}&{2}&ul={3}",
                                            _requestUrl, UnityEngine.Random.Range(1, 99999), data, Localizer.Language);
                    }
                }

                if (url != null)
                {
                    UnityDebug.LogInfo("[GA REQUEST] " + url);

                    using (var www = new WWW(url)) {
                        yield return(www);
                    }
                    url = null;
                }
                else
                {
                    yield return(null);
                }
            }
        }