コード例 #1
0
        protected override void Start()
        {
            switch (DeviceStrategy)
            {
            case DeviceChooseStrategy.SystemVIOFirst:
                var arcoreFail = CheckARCore();
                if (!MotionTrackerCameraDevice.isAvailable() && !ARKitCameraDevice.isAvailable() && !ARCoreCameraDevice.isAvailable())
                {
                    throw new UIPopupException("VIOCameraDevice not available");
                }
                if (arcoreFail)
                {
                    GUIPopup.EnqueueMessage(typeof(MotionTrackerCameraDevice) + " selected", 3);
                }
                break;

            case DeviceChooseStrategy.EasyARMotionTrackerFirst:
                if (!MotionTrackerCameraDevice.isAvailable())
                {
                    CheckARCore();
                }
                if (!MotionTrackerCameraDevice.isAvailable() && !ARKitCameraDevice.isAvailable() && !ARCoreCameraDevice.isAvailable())
                {
                    throw new UIPopupException("VIOCameraDevice not available");
                }
                break;

            case DeviceChooseStrategy.SystemVIOOnly:
                CheckARCore();
                if (!ARKitCameraDevice.isAvailable() && Application.platform == RuntimePlatform.IPhonePlayer)
                {
                    throw new UIPopupException(typeof(ARKitCameraDevice) + " not available");
                }
                else if (!ARCoreCameraDevice.isAvailable() && Application.platform == RuntimePlatform.Android)
                {
                    throw new UIPopupException(typeof(ARCoreCameraDevice) + " not available");
                }
                else if (!ARKitCameraDevice.isAvailable() && !ARCoreCameraDevice.isAvailable())
                {
                    throw new UIPopupException("System VIO not available");
                }
                break;

            case DeviceChooseStrategy.EasyARMotionTrackerOnly:
                if (!MotionTrackerCameraDevice.isAvailable())
                {
                    throw new UIPopupException(typeof(MotionTrackerCameraDevice) + " not available");
                }
                break;

            default:
                break;
            }

            base.Start();
        }
コード例 #2
0
        /// <summary>
        /// MonoBehaviour Start
        /// </summary>
        protected override void Start()
        {
#if UNITY_ANDROID && !UNITY_EDITOR
            if (Application.platform == RuntimePlatform.Android)
            {
                try
                {
                    using (var systemClass = new AndroidJavaClass("java.lang.System"))
                    {
                        systemClass.CallStatic("loadLibrary", "arcore_sdk_c");
                    }
                    arcoreLoaded = true;
                }
                catch (AndroidJavaException) { }
            }
#endif
            if (UpdateCalibrationOnStart && Application.platform == RuntimePlatform.Android)
            {
                // NOTE:
                // This downloader instance will return asynchronously. Latest calibration may not be used in the first time.
                // You can setup the download procedure in your own code if latest calibration usage is desired before tracking start.
                var downloader = new CalibrationDownloader();
                downloader.download(EasyARController.Scheduler, (status, error) =>
                {
                    switch (status)
                    {
                    case CalibrationDownloadStatus.Successful:
                        Debug.Log("Calibration file has been updated.");
                        break;

                    case CalibrationDownloadStatus.NotModified:
                        Debug.Log("Calibration file is up to date.");
                        break;

                    default:
                        Debug.LogError("Error download calibration file, " + status + ": " + error);
                        break;
                    }
                    downloader.Dispose();
                });
            }

            switch (DeviceStrategy)
            {
            case DeviceChooseStrategy.SystemVIOFirst:
                var arcoreFail = CheckARCore();
                if (!MotionTrackerCameraDevice.isAvailable() && !ARKitCameraDevice.isAvailable() && !ARCoreCameraDevice.isAvailable())
                {
                    throw new UIPopupException("VIOCameraDevice not available");
                }
                if (!ARKitCameraDevice.isAvailable() && !ARCoreCameraDevice.isAvailable() && MotionTrackerCameraDevice.isAvailable() && MotionTrackerCameraDevice.getQualityLevel() < DesiredMotionTrackerParameters.MinQualityLevel)
                {
                    throw new UIPopupException("VIOCameraDevice available but disabled with quality level (" + MotionTrackerCameraDevice.getQualityLevel() + "), min level is set to " + DesiredMotionTrackerParameters.MinQualityLevel);
                }
                if (arcoreFail)
                {
                    GUIPopup.EnqueueMessage(typeof(MotionTrackerCameraDevice) + " selected", 3);
                }
                break;

            case DeviceChooseStrategy.EasyARMotionTrackerFirst:
                if (!MotionTrackerCameraDevice.isAvailable())
                {
                    CheckARCore();
                }
                if (!MotionTrackerCameraDevice.isAvailable() && !ARKitCameraDevice.isAvailable() && !ARCoreCameraDevice.isAvailable())
                {
                    throw new UIPopupException("VIOCameraDevice not available");
                }
                if (MotionTrackerCameraDevice.isAvailable() && MotionTrackerCameraDevice.getQualityLevel() < DesiredMotionTrackerParameters.MinQualityLevel)
                {
                    throw new UIPopupException("VIOCameraDevice available but disabled with quality level (" + MotionTrackerCameraDevice.getQualityLevel() + "), min level is set to " + DesiredMotionTrackerParameters.MinQualityLevel);
                }
                break;

            case DeviceChooseStrategy.SystemVIOOnly:
                CheckARCore();
                if (!ARKitCameraDevice.isAvailable() && Application.platform == RuntimePlatform.IPhonePlayer)
                {
                    throw new UIPopupException(typeof(ARKitCameraDevice) + " not available");
                }
                else if (!ARCoreCameraDevice.isAvailable() && Application.platform == RuntimePlatform.Android)
                {
                    throw new UIPopupException(typeof(ARCoreCameraDevice) + " not available");
                }
                else if (!ARKitCameraDevice.isAvailable() && !ARCoreCameraDevice.isAvailable())
                {
                    throw new UIPopupException("System VIO not available");
                }
                break;

            case DeviceChooseStrategy.EasyARMotionTrackerOnly:
                if (!MotionTrackerCameraDevice.isAvailable())
                {
                    throw new UIPopupException(typeof(MotionTrackerCameraDevice) + " not available");
                }
                if (MotionTrackerCameraDevice.getQualityLevel() < DesiredMotionTrackerParameters.MinQualityLevel)
                {
                    throw new UIPopupException(typeof(MotionTrackerCameraDevice) + " available but disabled with quality level (" + MotionTrackerCameraDevice.getQualityLevel() + "), min level is set to " + DesiredMotionTrackerParameters.MinQualityLevel);
                }
                break;

            default:
                break;
            }

            base.Start();
        }
コード例 #3
0
        public override void Open()
        {
            willOpen = true;
            CameraDevice.requestPermissions(EasyARController.Scheduler, (Action <PermissionStatus, string>)((status, msg) =>
            {
                if (!willOpen)
                {
                    return;
                }
                if (status != PermissionStatus.Granted)
                {
                    Debug.LogError("Camera permission not granted");
                    return;
                }

                Close();

                switch (DeviceStrategy)
                {
                case DeviceChooseStrategy.SystemVIOFirst:
                    if (ARKitCameraDevice.isAvailable())
                    {
                        CreateARKitCameraDevice();
                    }
                    else if (ARCoreCameraDevice.isAvailable())
                    {
                        CreateARCoreCameraDevice();
                    }
                    else if (MotionTrackerCameraDevice.isAvailable())
                    {
                        CreateMotionTrackerCameraDevice();
                    }
                    break;

                case DeviceChooseStrategy.EasyARMotionTrackerFirst:
                    if (MotionTrackerCameraDevice.isAvailable())
                    {
                        CreateMotionTrackerCameraDevice();
                    }
                    else if (ARKitCameraDevice.isAvailable())
                    {
                        CreateARKitCameraDevice();
                    }
                    else if (ARCoreCameraDevice.isAvailable())
                    {
                        CreateARCoreCameraDevice();
                    }
                    break;

                case DeviceChooseStrategy.SystemVIOOnly:
                    if (ARKitCameraDevice.isAvailable())
                    {
                        CreateARKitCameraDevice();
                    }
                    else if (ARCoreCameraDevice.isAvailable())
                    {
                        CreateARCoreCameraDevice();
                    }
                    break;

                case DeviceChooseStrategy.EasyARMotionTrackerOnly:
                    if (MotionTrackerCameraDevice.isAvailable())
                    {
                        CreateMotionTrackerCameraDevice();
                    }
                    break;

                default:
                    break;
                }
                if (DeviceCreated != null)
                {
                    DeviceCreated();
                }

                if (bufferCapacity != 0)
                {
                    deviceSetBufferCapacity(bufferCapacity);
                }

                if (sink != null)
                {
                    deviceConnect(sink);
                }

                if (enabled)
                {
                    OnEnable();
                }

                if (DeviceOpened != null)
                {
                    DeviceOpened();
                }
            }));
        }
コード例 #4
0
        /// <summary>
        /// MonoBehaviour Start
        /// </summary>
        protected override void Start()
        {
            if (UpdateCalibrationOnStart && Application.platform == RuntimePlatform.Android)
            {
                // NOTE:
                // This downloader instance will return asynchronously. Latest calibration may not be used in the first time.
                // You can setup the download procedure in your own code if latest calibration usage is desired before tracking start.
                var downloader = new CalibrationDownloader();
                downloader.download(EasyARController.Scheduler, (status, error) =>
                {
                    switch (status)
                    {
                    case CalibrationDownloadStatus.Successful:
                        Debug.Log("Calibration file has been updated.");
                        break;

                    case CalibrationDownloadStatus.NotModified:
                        Debug.Log("Calibration file is up to date.");
                        break;

                    default:
                        Debug.LogError("Error download calibration file, " + status + ": " + error);
                        break;
                    }
                    downloader.Dispose();
                });
            }

            switch (DeviceStrategy)
            {
            case DeviceChooseStrategy.SystemVIOFirst:
                var arcoreFail = CheckARCore();
                if (!MotionTrackerCameraDevice.isAvailable() && !ARKitCameraDevice.isAvailable() && !ARCoreCameraDevice.isAvailable())
                {
                    throw new UIPopupException("VIOCameraDevice not available");
                }
                if (arcoreFail)
                {
                    GUIPopup.EnqueueMessage(typeof(MotionTrackerCameraDevice) + " selected", 3);
                }
                break;

            case DeviceChooseStrategy.EasyARMotionTrackerFirst:
                if (!MotionTrackerCameraDevice.isAvailable())
                {
                    CheckARCore();
                }
                if (!MotionTrackerCameraDevice.isAvailable() && !ARKitCameraDevice.isAvailable() && !ARCoreCameraDevice.isAvailable())
                {
                    throw new UIPopupException("VIOCameraDevice not available");
                }
                break;

            case DeviceChooseStrategy.SystemVIOOnly:
                CheckARCore();
                if (!ARKitCameraDevice.isAvailable() && Application.platform == RuntimePlatform.IPhonePlayer)
                {
                    throw new UIPopupException(typeof(ARKitCameraDevice) + " not available");
                }
                else if (!ARCoreCameraDevice.isAvailable() && Application.platform == RuntimePlatform.Android)
                {
                    throw new UIPopupException(typeof(ARCoreCameraDevice) + " not available");
                }
                else if (!ARKitCameraDevice.isAvailable() && !ARCoreCameraDevice.isAvailable())
                {
                    throw new UIPopupException("System VIO not available");
                }
                break;

            case DeviceChooseStrategy.EasyARMotionTrackerOnly:
                if (!MotionTrackerCameraDevice.isAvailable())
                {
                    throw new UIPopupException(typeof(MotionTrackerCameraDevice) + " not available");
                }
                break;

            default:
                break;
            }

            base.Start();
        }