Пример #1
0
        /// <summary>
        /// Loads previous settings.
        /// </summary>
        public void Load()
        {
            // Default settings.
            IsIOSSupportEnabled = false;
            AndroidAuthenticationStrategySetting = AndroidAuthenticationStrategy.DoNotUse;
            IOSAuthenticationStrategySetting     = IOSAuthenticationStrategy.DoNotUse;
            AndroidCloudServicesApiKey           = string.Empty;
            IOSCloudServicesApiKey = string.Empty;

            if (File.Exists(_projectSettingsPath))
            {
                ARCoreExtensionsProjectSettings settings =
                    JsonUtility.FromJson <ARCoreExtensionsProjectSettings>(
                        File.ReadAllText(_projectSettingsPath));
                foreach (FieldInfo fieldInfo in this.GetType().GetFields())
                {
                    fieldInfo.SetValue(this, fieldInfo.GetValue(settings));
                }
            }

            if (!string.IsNullOrEmpty(AndroidCloudServicesApiKey))
            {
                AndroidAuthenticationStrategySetting = AndroidAuthenticationStrategy.ApiKey;
            }

            if (!string.IsNullOrEmpty(IOSCloudServicesApiKey))
            {
                IOSAuthenticationStrategySetting = IOSAuthenticationStrategy.ApiKey;
            }

            // Update the settings version as needed.
            Version = VersionInfo.Version;
        }
Пример #2
0
        public void Load()
        {
            Version                 = GoogleARCore.VersionInfo.Version;
            IsARCoreRequired        = true;
            IsInstantPreviewEnabled = true;
            CloudServicesApiKey     = string.Empty;
            IosCloudServicesApiKey  = string.Empty;
            AndroidAuthenticationStrategySetting = AndroidAuthenticationStrategy.DoNotUse;
            IOSAuthenticationStrategySetting     = IOSAuthenticationStrategy.DoNotUse;

            string absolutePath = Application.dataPath + "/../" + _projectSettingsPath;

            if (File.Exists(absolutePath))
            {
                ARCoreProjectSettings settings = JsonUtility.FromJson <ARCoreProjectSettings>(
                    File.ReadAllText(absolutePath));
                foreach (FieldInfo fieldInfo in this.GetType().GetFields())
                {
                    fieldInfo.SetValue(this, fieldInfo.GetValue(settings));
                }
            }
            else
            {
                Debug.Log("Cannot find ARCoreProjectSettings at " + absolutePath);
            }

            if (!string.IsNullOrEmpty(CloudServicesApiKey))
            {
                AndroidAuthenticationStrategySetting = AndroidAuthenticationStrategy.ApiKey;
            }

            if (!string.IsNullOrEmpty(IosCloudServicesApiKey))
            {
                IOSAuthenticationStrategySetting = IOSAuthenticationStrategy.ApiKey;
            }

            // Upgrades settings from V1.0.0 to V1.1.0.
            if (Version.Equals("V1.0.0"))
            {
                IsInstantPreviewEnabled = true;
                Version = "V1.1.0";
            }

            // Upgrades setting from V1.1.0 and V1.2.0 to V1.3.0.
            // Note: V1.2.0 went out with _versionString = V1.1.0
            if (Version.Equals("V1.1.0"))
            {
                IosCloudServicesApiKey = CloudServicesApiKey;
                Version = "V1.3.0";
            }

            if (!Version.Equals(GoogleARCore.VersionInfo.Version))
            {
                Version = GoogleARCore.VersionInfo.Version;
            }
        }
        /// <summary>
        /// Loads previous settings.
        /// </summary>
        public void Load()
        {
            // Default settings.
            IsIOSSupportEnabled = false;
            AndroidAuthenticationStrategySetting = AndroidAuthenticationStrategy.DoNotUse;
            IOSAuthenticationStrategySetting     = IOSAuthenticationStrategy.DoNotUse;
            AndroidCloudServicesApiKey           = string.Empty;
            IOSCloudServicesApiKey = string.Empty;

            if (File.Exists(_projectSettingsPath))
            {
                ARCoreExtensionsProjectSettings settings =
                    JsonUtility.FromJson <ARCoreExtensionsProjectSettings>(
                        File.ReadAllText(_projectSettingsPath));
                foreach (FieldInfo fieldInfo in this.GetType().GetFields())
                {
                    fieldInfo.SetValue(this, fieldInfo.GetValue(settings));
                }

                // Set the initial value in previous settings to keep Cloud Anchors enabled.
                int[] versions = string.IsNullOrEmpty(Version) ? new int[0] :
                                 Array.ConvertAll(
                    Version.Split('.'),
                    s => { int.TryParse(s, out int num); return(num); });
                if (versions.Length == 3 && versions[0] == 1 && versions[1] <= 30)
                {
                    CloudAnchorEnabled = true;
                }
            }

            if (!string.IsNullOrEmpty(AndroidCloudServicesApiKey))
            {
                AndroidAuthenticationStrategySetting = AndroidAuthenticationStrategy.ApiKey;
            }

            if (!string.IsNullOrEmpty(IOSCloudServicesApiKey))
            {
                IOSAuthenticationStrategySetting = IOSAuthenticationStrategy.ApiKey;
            }

            // Update the settings version as needed.
            Version = VersionInfo.Version;
        }