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); }
void Init() { //If you do not want to switch engines, AREnginesSelector is useless. // You just need to use AREnginesApk.Instance.requestInstall() and the default engine // is Huawei AR Engine. AREnginesAvaliblity ability = AREnginesSelector.Instance.CheckDeviceExecuteAbility(); if ((AREnginesAvaliblity.HUAWEI_AR_ENGINE & ability) != 0) { AREnginesSelector.Instance.SetAREngine(AREnginesType.HUAWEI_AR_ENGINE); ImmersalSDK.isHWAR = true; if (app) { errorMessage = "Your device supports AR!"; Log(); errorMessage = "Starting AR session..."; Log(); } } else { errorMessage = "This device does not support AR Engine. Exit."; Log(); Invoke("_DoQuit", 0.5f); return; } try { switch (AREnginesApk.Instance.RequestInstall(!installRequested)) { case ARInstallStatus.INSTALL_REQUESTED: installRequested = true; return; case ARInstallStatus.INSTALLED: break; } } catch (ARUnavailableConnectServerTimeOutException e) { errorMessage = "Network is not available, retry later!"; Log(); Invoke("_DoQuit", 0.5f); return; } catch (ARUnavailableDeviceNotCompatibleException e) { errorMessage = "This Device does not support AR!"; Log(); Invoke("_DoQuit", 0.5f); return; } catch (ARUnavailableEmuiNotCompatibleException e) { errorMessage = "This EMUI does not support AR!"; Log(); Invoke("_DoQuit", 0.5f); return; } catch (ARUnavailableUserDeclinedInstallationException e) { errorMessage = "User decline installation right now, quit"; Log(); Invoke("_DoQuit", 0.5f); return; } if (isFirstConnect) { _Connect(); isFirstConnect = false; } if (Config != null) { isEnableMask = Config.EnableMask; } }