예제 #1
0
        public void SetConfiguration(MapboxConfiguration configuration, bool throwExecptions = true)
        {
            if (configuration == null)
            {
                if (throwExecptions)
                {
                    throw new InvalidTokenException("No configuration file found! Configure your access token from the Mapbox > Settings menu.");
                }
            }

            TokenValidator.Retrieve(configuration.AccessToken, (response) =>
            {
                if (OnTokenValidation != null)
                {
                    OnTokenValidation(response.Status);
                }

                if (response.Status != MapboxTokenStatus.TokenValid &&
                    throwExecptions)
                {
                    throw new InvalidTokenException(response.Status.ToString());
                }
            });

            _configuration = configuration;

            ConfigureFileSource();
            ConfigureTelemetry();
        }
예제 #2
0
        /// <summary>
        /// Loads the access token from <see href="https://docs.unity3d.com/Manual/BestPracticeUnderstandingPerformanceInUnity6.html">Resources folder</see>.
        /// </summary>
        private void LoadAccessToken()
        {
            TextAsset configurationTextAsset = Resources.Load <TextAsset>(Constants.Path.MAPBOX_RESOURCES_RELATIVE);

#if !WINDOWS_UWP
            Configuration = configurationTextAsset == null ? null : JsonUtility.FromJson <MapboxConfiguration>(configurationTextAsset.text);
#else
            Configuration = configurationTextAsset == null ? null : Mapbox.Json.JsonConvert.DeserializeObject <MapboxConfiguration>(configurationTextAsset.text);
#endif
        }
예제 #3
0
        public void SetConfiguration(MapboxConfiguration configuration, bool throwExecptions = true)
        {
            if (configuration == null)
            {
                if (throwExecptions)
                {
                    throw new InvalidTokenException(_tokenNotSetErrorMessage);
                }
            }

            if (null == configuration || string.IsNullOrEmpty(configuration.AccessToken))
            {
                Debug.LogError(_tokenNotSetErrorMessage);
            }
            else
            {
                TokenValidator.Retrieve(configuration.GetMapsSkuToken, configuration.AccessToken, (response) =>
                {
                    if (OnTokenValidation != null)
                    {
                        OnTokenValidation(response.Status);
                    }

                    if (response.Status != MapboxTokenStatus.TokenValid &&
                        throwExecptions)
                    {
                        configuration.AccessToken = string.Empty;
                        Debug.Log("Exception Here");
                        Debug.LogError(new InvalidTokenException(response.Status.ToString().ToString()));
                    }
                });

                _configuration = configuration;

                ConfigureFileSource();
                ConfigureTelemetry();

                Configured = true;
            }
        }
예제 #4
0
 public void SetConfiguration(MapboxConfiguration configuration)
 {
     _configuration = configuration;
 }