Ejemplo n.º 1
0
        private static void VerifyAndroidAuthentication()
        {
            CloudAnchorMode mode = GetActiveCloudAnchorMode();
            string          projectSettingPath =
                "Project Settings > Google ARCore > Android Authentication Strategy";

            switch (mode)
            {
            case CloudAnchorMode.Disabled:
                if (ARCoreProjectSettings.Instance.AndroidAuthenticationStrategySetting !=
                    AndroidAuthenticationStrategy.DoNotUse)
                {
                    Debug.LogWarningFormat(
                        "{0} authentication is selected in ARCore Project Settings but " +
                        "Cloud Anchor is not used in any Scenes in Build. To turn off {0}, " +
                        "select Do Not Use in {1}.",
                        ARCoreProjectSettings.Instance.AndroidAuthenticationStrategySetting,
                        projectSettingPath);
                }

                break;

            case CloudAnchorMode.Enabled:
                if (ARCoreProjectSettings.Instance.AndroidAuthenticationStrategySetting ==
                    AndroidAuthenticationStrategy.DoNotUse)
                {
                    throw new BuildFailedException(string.Format(
                                                       "Cloud Anchor authentication is required by CloudAnchorMode {0}. " +
                                                       "An Android Authentication Strategy must be set in {1} " +
                                                       "when CloudAnchorMode is {0}", mode, projectSettingPath));
                }

                break;
            }
        }
Ejemplo n.º 2
0
 /// <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;
 }
 /// <summary>
 /// ValueType copy from another SessionConfig object into this one.
 /// </summary>
 /// <param name="other">The SessionConfig to copy from.</param>
 public void CopyFrom(ARCoreSessionConfig other)
 {
     MatchCameraFramerate   = other.MatchCameraFramerate;
     PlaneFindingMode       = other.PlaneFindingMode;
     LightEstimationMode    = other.LightEstimationMode;
     CloudAnchorMode        = other.CloudAnchorMode;
     AugmentedImageDatabase = other.AugmentedImageDatabase;
     CameraFocusMode        = other.CameraFocusMode;
     AugmentedFaceMode      = other.AugmentedFaceMode;
 }
Ejemplo n.º 4
0
        private static void VerifyIosAuthentication()
        {
#if ARCORE_IOS_SUPPORT
            CloudAnchorMode mode = GetActiveCloudAnchorMode();
            string          projectSettingPath =
                "Project Settings > Google ARCore > iOS Authentication Strategy";
            switch (mode)
            {
            case CloudAnchorMode.Disabled:
                if (ARCoreProjectSettings.Instance.IOSAuthenticationStrategySetting ==
                    IOSAuthenticationStrategy.DoNotUse)
                {
                    Debug.LogWarning(
                        "Cloud Anchor APIs require one of the iOS authentication strategies. " +
                        "If it’s not in use, you can uncheck iOS Support Enabled in " +
                        "Project Settings > Google ARCore so ARCore SDK for Unity " +
                        "won’t import Cloud Anchor iOS cocoapod into your project.");
                }
                else
                {
                    Debug.LogWarningFormat(
                        "{0} authentication is selected in ARCore Project Settings but " +
                        "Cloud Anchor is not used in any Scenes in Build. To turn off {0}, " +
                        "select Do Not Use in {1}.",
                        ARCoreProjectSettings.Instance.IOSAuthenticationStrategySetting,
                        projectSettingPath);
                }

                break;

            case CloudAnchorMode.Enabled:
                if (ARCoreProjectSettings.Instance.IOSAuthenticationStrategySetting ==
                    IOSAuthenticationStrategy.DoNotUse)
                {
                    throw new BuildFailedException(string.Format(
                                                       "Cloud Anchor authentication is required by CloudAnchorMode {0}. " +
                                                       "An iOS Authentication Strategy must be set in {1} " +
                                                       "when CloudAnchorMode is {0}", mode, projectSettingPath));
                }

                break;
            }

            if (mode != CloudAnchorMode.Disabled &&
                ARCoreProjectSettings.Instance.IOSAuthenticationStrategySetting ==
                IOSAuthenticationStrategy.AuthenticationToken)
            {
                Debug.Log(
                    "Authentication Token is selected as the Cloud Anchor Authentication. " +
                    "To authenticate with the Google Cloud Anchor Service, use " +
                    "XPSession.SetAuthToken(string) in runtime.");
            }
#endif
        }
Ejemplo n.º 5
0
        private static CloudAnchorMode GetActiveCloudAnchorMode()
        {
            CloudAnchorMode mode = CloudAnchorMode.Disabled;

            foreach (ARCoreSessionConfig config in
                     AndroidDependenciesHelper.GetAllSessionConfigs().Keys)
            {
                if (config.CloudAnchorMode > mode)
                {
                    mode = config.CloudAnchorMode;
                }
            }

            return(mode);
        }
        public static ApiCloudAnchorMode ToApiCloudAnchorMode(this CloudAnchorMode mode)
        {
            switch (mode)
            {
            case CloudAnchorMode.Disabled:
                return(ApiCloudAnchorMode.Disabled);

            case CloudAnchorMode.Enabled:
                return(ApiCloudAnchorMode.Enabled);

            default:
                Debug.LogErrorFormat("Unexpected CloudAnchorMode {0}", mode);
                return(ApiCloudAnchorMode.Disabled);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Checking whether location module is compatible with given Project Settings.
        /// If it returns false, the preprocessbuild will throw a general Build Failure Error
        /// with detailed error messages.
        /// </summary>
        /// <param name="settings">ARCore Extensions Project Settings.</param>
        /// <param name="sessionConfig">ARCore Extensions Config.</param>
        /// <returns>The boolean shows whether the ARCoreExtensionsProjectSettings is compatible
        /// with the ARCoreExtensionsConfig.</returns>
        public override bool IsCompatibleWithSessionConfig(ARCoreExtensionsProjectSettings settings,
                                                           ARCoreExtensionsConfig sessionConfig)
        {
            CloudAnchorMode cloudAnchorMode = sessionConfig.CloudAnchorMode;
            bool            isRequired      =
                cloudAnchorMode == CloudAnchorMode.EnabledWithEarthLocalization;

            if (isRequired && !IsEnabled(settings))
            {
                Debug.LogErrorFormat(
                    "LocationModule is required by CloudAnchorMode {0}. Navigate to " +
                    "'Project Settings > XR > ARCore Extensions' and select " +
                    "Earth Cloud Anchor Enabled.", cloudAnchorMode);
                return(false);
            }
            else
            {
                return(true);
            }
        }
 /// <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;
 }
Ejemplo n.º 9
0
        private void OnFrameUpdate(ARCameraFrameEventArgs frameEventArgs)
        {
            if (!ShouldUpdateARCoreSession())
            {
                return;
            }

            if (_sessionHandle == IntPtr.Zero)
            {
                return;
            }

            if (_frameHandle != IntPtr.Zero)
            {
                SessionApi.ReleaseFrame(_frameHandle);
                _frameHandle = IntPtr.Zero;
            }

            if (_arKitSession != null && _cameraManager != null && _arKitSession.enabled)
            {
                var cameraParams = new XRCameraParams
                {
                    zNear             = _cameraManager.GetComponent <Camera>().nearClipPlane,
                    zFar              = _cameraManager.GetComponent <Camera>().farClipPlane,
                    screenWidth       = Screen.width,
                    screenHeight      = Screen.height,
                    screenOrientation = Screen.orientation
                };

                if (!_cameraManager.subsystem.TryGetLatestFrame(
                        cameraParams, out XRCameraFrame frame))
                {
                    Debug.LogWarning("XRCamera's latest frame is not available now.");
                    return;
                }

                if (frame.timestampNs == 0 || frame.FrameHandle() == IntPtr.Zero)
                {
                    Debug.LogWarning("ARKit Plugin Frame is not ready.");
                    return;
                }

                var status = ExternApi.ArSession_updateAndAcquireArFrame(
                    _sessionHandle, frame.FrameHandle(), ref _frameHandle);
                if (status != ApiArStatus.Success)
                {
                    Debug.LogErrorFormat("Failed to update and acquire ARFrame with error: " +
                                         "{0}", status);
                    return;
                }

                if (_cachedCloudAnchorMode !=
                    ARCoreExtensions._instance.ARCoreExtensionsConfig.CloudAnchorMode)
                {
                    ApiCloudAnchorMode mode = (ApiCloudAnchorMode)
                                              ARCoreExtensions._instance.ARCoreExtensionsConfig.CloudAnchorMode;
                    status = ExternApi.ArSession_setCloudAnchorMode(_sessionHandle, mode);
                    if (status != ApiArStatus.Success)
                    {
                        Debug.LogErrorFormat(
                            "Could not set CloudAnchorMode {0} ({1}).", mode, status);
                        return;
                    }
                    else
                    {
                        Debug.LogFormat("Set Cloud Anchor Mode to {0}.", mode);
                    }

                    _cachedCloudAnchorMode =
                        ARCoreExtensions._instance.ARCoreExtensionsConfig.CloudAnchorMode;
                }
            }
        }