コード例 #1
0
        private void SetupGeolocator()
        {
            if (!_useLocation)
            {
                return;
            }

            try
            {
                UnityApp.EnableLocationService(true);
                Geolocator geolocator = new Geolocator();
                geolocator.ReportInterval = 5000;
                IAsyncOperation <Geoposition> op = geolocator.GetGeopositionAsync();
                op.Completed += (asyncInfo, asyncStatus) =>
                {
                    if (asyncStatus == AsyncStatus.Completed)
                    {
                        Geoposition geoposition = asyncInfo.GetResults();
                        UnityApp.SetupGeolocator(geolocator, geoposition);
                    }
                    else
                    {
                        UnityApp.SetupGeolocator(null, null);
                    }
                };
            }
            catch (Exception)
            {
                UnityApp.SetupGeolocator(null, null);
            }
        }