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); } }
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); }