コード例 #1
0
ファイル: Locator.cs プロジェクト: grimlor/GGJ_SpyHeart
    private void Update()
    {
        if(_callback != null)
        {
            // First, check if user has location service enabled
            if (!Input.location.isEnabledByUser)
            {
                _callback(new LocationResult(false, "Location Service Not Enabled"));
                _callback = null;
                return;
            }

            _maxWait -= Time.deltaTime;
            if(_maxWait < 0f)
            {
                _callback(new LocationResult(false, "Location service didn't initialize in 20 seconds"));
                _callback = null;
                return;
            }

            if(Input.location.status != LocationServiceStatus.Initializing)
            {
                if (Input.location.status == LocationServiceStatus.Failed)
                {
                    _callback(new LocationResult(false, "Location service failed"));
                    _callback = null;
                    return;
                }

                _callback(new LocationResult(true, "Success"));
                _callback = null;
                return;
            }
        }
    }
コード例 #2
0
ファイル: Locator.cs プロジェクト: grimlor/GGJ_SpyHeart
    public void InitializeLocationServices(OnLocationServiceInitialized callback)
    {
        _maxWait = 20f;
        _callback = callback;

        // Start service before querying location
        Input.location.Start(5f, 5f);
    }