Beispiel #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
        }
 /// <summary>
 /// ValueType copy from another ARCoreExtensionsConfig object into this one.
 /// </summary>
 /// <param name="otherConfig">The ARCoreExtensionsConfig to copy from.</param>
 public void CopyFrom(ARCoreExtensionsConfig otherConfig)
 {
     CloudAnchorMode   = otherConfig.CloudAnchorMode;
     SegmentationMode  = otherConfig.SegmentationMode;
     DepthModeOverride = otherConfig.DepthModeOverride;
     UseHorizontalAndVerticalLowFeatureGrowth =
         otherConfig.UseHorizontalAndVerticalLowFeatureGrowth;
 }
Beispiel #3
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
        }
        /// <summary>
        /// ValueType check if two ARCoreExtensionsConfig objects are equal.
        /// </summary>
        /// <param name="other">The other ARCoreExtensionsConfig.</param>
        /// <returns>True if the two ARCoreExtensionsConfig objects are value-type equal,
        /// otherwise false.</returns>
        public override bool Equals(object other)
        {
            ARCoreExtensionsConfig otherConfig = other as ARCoreExtensionsConfig;

            if (otherConfig == null ||
                CloudAnchorMode != otherConfig.CloudAnchorMode)
            {
                return(false);
            }

            return(true);
        }
        /// <summary>
        /// ValueType check if two ARCoreExtensionsConfig objects are equal.
        /// </summary>
        /// <param name="other">The other ARCoreExtensionsConfig.</param>
        /// <returns>True if the two ARCoreExtensionsConfig objects are value-type equal,
        /// otherwise false.</returns>
        public override bool Equals(object other)
        {
            ARCoreExtensionsConfig otherConfig = other as ARCoreExtensionsConfig;

            if (otherConfig == null ||
                SegmentationMode != otherConfig.SegmentationMode ||
                UseHorizontalAndVerticalLowFeatureGrowth !=
                otherConfig.UseHorizontalAndVerticalLowFeatureGrowth ||
                CloudAnchorMode != otherConfig.CloudAnchorMode)
            {
                return(false);
            }

            return(true);
        }
        /// <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
        }
 /// <summary>
 /// ValueType copy from another ARCoreExtensionsConfig object into this one.
 /// </summary>
 /// <param name="otherConfig">The ARCoreExtensionsConfig to copy from.</param>
 public void CopyFrom(ARCoreExtensionsConfig otherConfig)
 {
     CloudAnchorMode = otherConfig.CloudAnchorMode;
 }