public void OnApplicationPause(bool isPaused) { if (isPaused) { ARSession.Pause(); } else { if (!isSessionCreated) { Init(); } if (isErrorHappendWhenInit) { return; } try { ARSession.Resume(); } catch (ARCameraPermissionDeniedException e) { ARDebug.LogError("camera permission is denied"); errorMessage = "This app require camera permission"; Log(); Invoke("_DoQuit", 0.5f); } } }
protected override void OnResume() { Log.Debug(TAG, "OnResume"); base.OnResume(); mDisplayRotationManager.RegisterDisplayListener(); Exception exception = null; message = null; if (mArSession == null) { try { if (!ArEngineAbilityCheck()) { Finish(); return; } mArSession = new ARSession(this); mArConfig = new ARFaceTrackingConfig(mArSession); mArConfig.SetPowerMode(ARConfigBase.PowerMode.PowerSaving); if (isOpenCameraOutside) { mArConfig.SetImageInputMode(ARConfigBase.ImageInputMode.ExternalInputAll); } mArSession.Configure(mArConfig); } catch (Exception capturedException) { exception = capturedException; SetMessageWhenError(capturedException); } if (message != null) { StopArSession(exception); return; } } try { mArSession.Resume(); } catch (ARCameraNotAvailableException e) { Toast.MakeText(this, "Camera open failed, please restart the app", ToastLength.Short).Show(); mArSession = null; return; } mDisplayRotationManager.RegisterDisplayListener(); SetCamera(); mFaceRenderManager.SetArSession(mArSession); mFaceRenderManager.SetOpenCameraOutsideFlag(isOpenCameraOutside); mFaceRenderManager.SetTextureId(textureId); glSurfaceView.OnResume(); }
protected override void OnResume() { Log.Debug(TAG, "onResume"); base.OnResume(); Exception exception = null; message = null; if (mArSession == null) { try { if (!ArEngineAbilityCheck()) { Finish(); return; } mArSession = new ARSession(this); ARBodyTrackingConfig config = new ARBodyTrackingConfig(mArSession); config.EnableItem = ARConfigBase.EnableDepth | ARConfigBase.EnableMask; mArSession.Configure(config); mBodyRenderManager.SetArSession(mArSession); } catch (Exception capturedException) { exception = capturedException; SetMessageWhenError(capturedException); } if (message != null) { Toast.MakeText(this, message, ToastLength.Long).Show(); Log.Debug(TAG, "Creating session" + exception.Message); if (mArSession != null) { mArSession.Stop(); mArSession = null; } return; } } try { mArSession.Resume(); } catch (ARCameraNotAvailableException e) { Toast.MakeText(this, "Camera open failed, please restart the app", ToastLength.Long).Show(); mArSession = null; return; } mSurfaceView.OnResume(); mDisplayRotationManager.RegisterDisplayListener(); }
protected override void OnResume() { Log.Debug(TAG, "OnResume"); base.OnResume(); Exception exception = null; message = null; if (mArSession == null) { try { if (!ArEngineAbilityCheck()) { Finish(); return; } mArSession = new ARSession(this); ARHandTrackingConfig config = new ARHandTrackingConfig(mArSession); config.CameraLensFacing = ARConfigBase.CameraLensFacing.Front; config.SetPowerMode(ARConfigBase.PowerMode.UltraPowerSaving); long item = ARConfigBase.EnableDepth; config.EnableItem = item; mArSession.Configure(config); mHandRenderManager.SetArSession(mArSession); Log.Debug(TAG, "Item = " + config.EnableItem); } catch (Exception capturedException) { exception = capturedException; SetMessageWhenError(capturedException); } if (message != null) { StopArSession(exception); return; } } try { mArSession.Resume(); } catch (ARCameraNotAvailableException e) { Toast.MakeText(this, "Camera open failed, please restart the app", ToastLength.Long).Show(); mArSession = null; return; } mDisplayRotationManager.RegisterDisplayListener(); mSurfaceView.OnResume(); }
private void _ConnectToService() { try { ARSession.CreateSession(); isSessionCreated = true; ARSession.Config(Config); ARSession.Resume(); ARSession.SetCameraTextureNameAuto(); ARSession.SetDisplayGeometry(Screen.width, Screen.height); } catch (ARCameraPermissionDeniedException e) { isErrorHappendWhenInit = true; ARDebug.LogError("camera permission is denied"); errorMessage = "This app require camera permission"; Log(); Invoke("_DoQuit", 0.5f); } catch (ARUnavailableDeviceNotCompatibleException e) { isErrorHappendWhenInit = true; errorMessage = "This device does not support AR"; Log(); Invoke("_DoQuit", 0.5f); } catch (ARUnavailableServiceApkTooOldException e) { isErrorHappendWhenInit = true; errorMessage = "This AR Engine is too old, please update"; Log(); Invoke("_DoQuit", 0.5f); } catch (ARUnavailableServiceNotInstalledException e) { isErrorHappendWhenInit = true; errorMessage = "This app depend on AREngine.apk, please install it"; Log(); Invoke("_DoQuit", 0.5f); } catch (ARUnSupportedConfigurationException e) { isErrorHappendWhenInit = true; errorMessage = "This config is not supported on this device, exit now."; Log(); Invoke("_DoQuit", 0.5f); } }
protected override void OnResume() { Log.Debug(TAG, "OnResume"); base.OnResume(); Exception exception = null; message = null; if (mArSession == null) { try { if (!ArEngineAbilityCheck()) { Finish(); return; } mArSession = new ARSession(this); ARWorldTrackingConfig config = new ARWorldTrackingConfig(mArSession); config.SetFocusMode(ARConfigBase.FocusMode.AutoFocus); config.SemanticMode = (ARWorldTrackingConfig.SemanticPlane); mArSession.Configure(config); mWorldRenderManager.SetArSession(mArSession); } catch (Exception capturedException) { exception = capturedException; SetMessageWhenError(capturedException); } if (message != null) { StopArSession(exception); return; } } try { mArSession.Resume(); } catch (ARCameraNotAvailableException e) { Toast.MakeText(this, "Camera open failed, please restart the app", ToastLength.Long).Show(); mArSession = null; return; } mDisplayRotationManager.RegisterDisplayListener(); mSurfaceView.OnResume(); }
private bool IsAREngineSupported() { #if HAS_HUAWEI_ARENGINE try { AREnginesAvaliblity ability = AREnginesSelector.Instance.CheckDeviceExecuteAbility(); if ((AREnginesAvaliblity.HUAWEI_AR_ENGINE & ability) != 0) { AREnginesSelector.Instance.SetAREngine(AREnginesType.HUAWEI_AR_ENGINE); } else { return(false); } } catch (Exception e) { return(false); } GameObject go = null; try { go = Instantiate(AREnginePrefab); ARSession.CreateSession(); ARSession.Config(go.GetComponent <SessionComponent>().Config); ARSession.Resume(); ARSession.SetCameraTextureNameAuto(); ARSession.SetDisplayGeometry(Screen.width, Screen.height); ARSession.Pause(); ARSession.Stop(); Destroy(go); return(true); } catch (Exception e) { } if (go != null) { Destroy(go); } #endif return(false); }