Esempio n. 1
0
        private IEnumerator StartLocationServices()
        {
            StartLocation = DeviceLocation;

            if (useExternalGps)
            {
                externalReceiver.OnDataReceived.AddListener((data) =>
                {
                    DeviceLocation = JsonUtility.FromJson <Location>(data);
                });
                yield break;
            }

            /*
             *
             *
             *
             *
             */

            {
                //setting desired update interval
                var interval = new WaitForSeconds(updateInterval);
                if (!inputHandler.LocationService.isEnabledByUser)
                {
#if UNITY_ANDROID
                    Android.ShowAndroidToastMessage("Enable GPS", 4000);
#endif
                    yield return(new WaitWhile(() => !inputHandler.LocationService.isEnabledByUser));
                }

                //initializing location serivce with desired accuracy
                inputHandler.LocationService.Start(gpsAccuracy, updateDistance);

                while (inputHandler.LocationService.status == LocationServiceStatus.Initializing)
                {
                    yield return(interval);
                }

                if (inputHandler.LocationService.status == LocationServiceStatus.Failed)
                {
#if UNITY_ANDROID
                    Android.ShowAndroidToastMessage("Unable to determine device location", 4000);
#endif
                    yield break;
                }
                else
                {
                    //current device location update
                    while (true)
                    {
                        DeviceLocation = new Location(inputHandler.LocationService.lastData);
                        //DeviceLocation = new Location(inputHandler.LocationService.lastData.latitude,
                        //    inputHandler.LocationService.lastData.longitude);
                        yield return(interval);
                    }
                }
            }
        }
Esempio n. 2
0
        public bool IsUsed()
        {
            var value = keyWords.Exists(word => SystemInfo.deviceModel.Contains(word) || SystemInfo.deviceName.Contains(word));

#if UNITY_ANDROID
            if (value)
            {
                Android.ShowAndroidToastMessage(deviceName + " recognized");
            }
#endif
            return(value);
        }