Пример #1
0
        public bool Play()
        {
            if (isPrepared)
            {
                isPaused = false;
                if (enabled)
                {
                    player.resume();
                }
                return(true);
            }
            var path = FilePath;

            if (FilePathType == WritablePathType.PersistentDataPath)
            {
                path = Application.persistentDataPath + "/" + path;
            }
            isPrepared = player.start(path);
            isPaused   = false;
            if (isPrepared)
            {
                display = new DisplayEmulator();
                display.EmulateRotation(player.initalScreenRotation());
            }
            else
            {
                GUIPopup.EnqueueMessage(typeof(FramePlayer) + " fail to start with file: " + path, 5);
            }
            if (enabled)
            {
                OnEnable();
            }
            return(isPrepared);
        }
Пример #2
0
 private bool CheckARCore()
 {
     if (Application.platform == RuntimePlatform.Android && !arcoreLoaded)
     {
         GUIPopup.EnqueueMessage("Fail to load ARCore library: arcore_sdk_c.so not found", 3);
         return(true);
     }
     return(false);
 }
Пример #3
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();
        }
Пример #4
0
 private bool CheckARCore()
 {
     if (Application.platform == RuntimePlatform.Android && EasyARController.ARCoreLoadFailed)
     {
         GUIPopup.EnqueueMessage("Fail to load ARCore library: arcore_sdk_c.so not found" + Environment.NewLine +
                                 "You can turn off ARCore support on <EasyAR Settings> Asset", 3);
         return(true);
     }
     return(false);
 }
Пример #5
0
 private void ShowErrorMessage()
 {
     if (Application.isEditor || !Settings || string.IsNullOrEmpty(Settings.LicenseKey))
     {
         GUIPopup.EnqueueMessage(Engine.errorMessage() + Environment.NewLine +
                                 "Fill a valid Key in EasyAR Settings Asset" + Environment.NewLine +
                                 "Menu: EasyAR -> Sense -> Configuration" + Environment.NewLine +
                                 "Get from EasyAR Develop Center (www.easyar.com) -> SDK Authorization", 10000);
     }
     else
     {
         GUIPopup.EnqueueMessage(Engine.errorMessage() + Environment.NewLine +
                                 "Get from EasyAR Develop Center (www.easyar.com) -> SDK Authorization", 10000);
     }
 }
 /// <summary>
 /// MonoBehaviour OnEnable
 /// </summary>
 protected virtual void OnEnable()
 {
     if (recorder != null && isStarted)
     {
         var path = FilePath;
         if (FilePathType == WritablePathType.PersistentDataPath)
         {
             path = Application.persistentDataPath + "/" + path;
         }
         var status = recorder.start(path, arSession.Assembly.Display.Rotation);
         if (!status)
         {
             GUIPopup.EnqueueMessage(typeof(FrameRecorder) + " fail to start with file: " + path, 5);
         }
     }
 }
Пример #7
0
 public UIPopupException(string message, float seconds) : base(message)
 {
     GUIPopup.EnqueueMessage(message, seconds);
 }
Пример #8
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();
        }
        /// <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();
        }