Esempio n. 1
0
 private void StopArSession(Exception exception)
 {
     Log.Debug(TAG, "stopArSession start.");
     Toast.MakeText(this, message, ToastLength.Long).Show();
     Log.Debug(TAG, "Creating session error" + exception.Message);
     if (mArSession != null)
     {
         mArSession.Stop();
         mArSession = null;
     }
     Log.Debug(TAG, "stopArSession end.");
 }
 protected override void OnDestroy()
 {
     Log.Debug(TAG, "OnDestroy start.");
     base.OnDestroy();
     if (mArSession != null)
     {
         mArSession.Stop();
         mArSession = null;
     }
     Log.Debug(TAG, "OnDestroy end.");
 }
        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();
        }
Esempio n. 4
0
        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);
        }
 public void OnApplicationQuit()
 {
     ARSession.Stop();
     isFirstConnect   = true;
     isSessionCreated = false;
 }