Exemplo n.º 1
0
        /// <summary>
        /// Unity's Update method.
        /// </summary>
        public void Update()
        {
#if UNITY_ANDROID
            if (_requiredPermissionNames.Count > 0)
            {
                RequestPermission();
            }

            // Update ARCore session configuration.
            if (Session.SessionHandle() != IntPtr.Zero && ARCoreExtensionsConfig != null)
            {
                if (_cachedConfig != null && _cachedConfig.Equals(ARCoreExtensionsConfig))
                {
                    return;
                }

                _cachedConfig = ScriptableObject.CreateInstance <ARCoreExtensionsConfig>();
                _cachedConfig.CopyFrom(ARCoreExtensionsConfig);

                if (_requiredPermissionNames.Count > 0)
                {
                    RequestPermission();
                    return;
                }

                _arCoreSubsystem.SetConfigurationDirty();
            }
#endif
        }
Exemplo n.º 2
0
        /// <summary>
        /// Unity's Update method.
        /// </summary>
        public void Update()
        {
#if UNITY_ANDROID
            if (_requiredPermissionNames.Count > 0)
            {
                RequestPermission();
            }

            if (Session.SessionHandle() == IntPtr.Zero)
            {
                return;
            }

            // Update camera config filter
            if (CameraConfigFilter != null && !CameraConfigFilter.Equals(_cachedFilter))
            {
                _cachedFilter =
                    ScriptableObject.CreateInstance <ARCoreExtensionsCameraConfigFilter>();
                _cachedFilter.CopyFrom(CameraConfigFilter);

                // Extensions will attempt to select the camera config based on the filter
                // if it's in use, otherwise, relies on AR Foundation's default behavior.
                SelectCameraConfig();
            }

            // Update session configuration.
            if (ARCoreExtensionsConfig != null && !ARCoreExtensionsConfig.Equals(_cachedConfig))
            {
                _cachedConfig = ScriptableObject.CreateInstance <ARCoreExtensionsConfig>();
                _cachedConfig.CopyFrom(ARCoreExtensionsConfig);

                List <IDependentModule> modules = DependentModulesManager.GetModules();
                foreach (var module in modules)
                {
                    string[] permissions = module.GetRuntimePermissions(_cachedConfig);
                    foreach (var permission in permissions)
                    {
                        if (!AndroidPermissionsManager.IsPermissionGranted(permission))
                        {
                            _requiredPermissionNames.Add(permission);
                        }
                    }
                }

                if (_requiredPermissionNames.Count > 0)
                {
                    RequestPermission();
                    return;
                }

                if (!Application.isEditor)
                {
                    _arCoreSubsystem.SetConfigurationDirty();
                }
            }
#endif
        }
Exemplo n.º 3
0
        /// <summary>
        /// Unity's Update method.
        /// </summary>
        public void Update()
        {
            // Ensure Cloud Anchors are enabled or disabled as requested.
            IntPtr sessionHandle = Session.SessionHandle();

            if (sessionHandle != IntPtr.Zero)
            {
                SessionApi.EnableCloudAnchors(
                    sessionHandle,
                    ARCoreExtensionsConfig.EnableCloudAnchors);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Unity's Update method.
        /// </summary>
        public void Update()
        {
#if UNITY_ANDROID
            if (_requiredPermissionNames.Count > 0)
            {
                RequestPermission();
            }

            if (Session.SessionHandle() == IntPtr.Zero)
            {
                return;
            }

            // Update camera config filter
            if (CameraConfigFilter != null && !CameraConfigFilter.Equals(_cachedFilter))
            {
                _cachedFilter =
                    ScriptableObject.CreateInstance <ARCoreExtensionsCameraConfigFilter>();
                _cachedFilter.CopyFrom(CameraConfigFilter);

                // Extensions will attempt to select the camera config based on the filter
                // if it's in use, otherwise, relies on AR Foundation's default behavior.
                SelectCameraConfig();
            }

            // Update session configuration.
            if (ARCoreExtensionsConfig != null && !ARCoreExtensionsConfig.Equals(_cachedConfig))
            {
                _cachedConfig = ScriptableObject.CreateInstance <ARCoreExtensionsConfig>();
                _cachedConfig.CopyFrom(ARCoreExtensionsConfig);

                if (_cachedConfig.CloudAnchorMode == CloudAnchorMode.EnabledWithEarthLocalization &&
                    !AndroidPermissionsManager.IsPermissionGranted(_androidLocationPermissionName))
                {
                    _requiredPermissionNames.Add(_androidLocationPermissionName);
                }

                if (_requiredPermissionNames.Count > 0)
                {
                    RequestPermission();
                    return;
                }

                _arCoreSubsystem.SetConfigurationDirty();
            }
#endif
        }