/// Function executed when the script is started. /// Check the availability of the AR mode. /// @returns Return an ARSession object in terms of the availability of the execution mode. /// @see ARSession() public IEnumerator Start() { if ((ARSession.state == ARSessionState.None) || (ARSession.state == ARSessionState.CheckingAvailability)) { yield return(ARSession.CheckAvailability()); } if (ARSession.state == ARSessionState.Unsupported) { Debug.Log("No AR mode"); this.ARCamera.gameObject.SetActive(false); this.Camera.gameObject.SetActive(true); } else { this.ARCamera.gameObject.SetActive(true); this.Camera.gameObject.SetActive(false); } }
IEnumerator Start() { if ((ARSession.state == ARSessionState.None) || (ARSession.state == ARSessionState.CheckingAvailability)) { yield return(ARSession.CheckAvailability()); } if (ARSession.state == ARSessionState.Unsupported) { #if UNITY_EDITOR Debug.Log("The AR System is not supported"); #endif } else { ARSession.stateChanged += OnArStateChanged; } }
IEnumerator Start() { image = GetComponent <Image>(); if ((ARSession.state == ARSessionState.None) || (ARSession.state == ARSessionState.CheckingAvailability)) { yield return(ARSession.CheckAvailability()); } if (ARSession.state == ARSessionState.Unsupported) { // Start some fallback experience for unsupported devices } else { // Start the AR session Session.enabled = true; } }
private IEnumerator Start() { if (ARSession.state == ARSessionState.None || ARSession.state == ARSessionState.CheckingAvailability) { yield return(ARSession.CheckAvailability()); } if (ARSession.state == ARSessionState.Unsupported) { throw new System.Exception("Not supported"); } else { m_session.enabled = true; } if (m_trackedImage.descriptor.supportsMovingImages) { m_trackedImage.maxNumberOfMovingImages = 4; } }
IEnumerator Start() { if (ARSession.state == ARSessionState.None || ARSession.state == ARSessionState.CheckingAvailability) { yield return(ARSession.CheckAvailability()); } if (ARSession.state == ARSessionState.Unsupported) { m_Session.enabled = false; // Start some fallback experience for unsupported devices _ShowAndroidToastMessage("We're sorry, your device is unsupported with this application"); Invoke("_DoQuit", 0.5f); } else { // Start the AR session m_Session.enabled = true; //EventBroker.FireShowHandUIEvent(); } }
/// <summary>检查设备是否支持AR支持</summary> private IEnumerator CheckSupport() { yield return(ARSession.CheckAvailability()); //当前设备不支持AR功能 if (ARSession.state == ARSessionState.Unsupported) { OnUnsupported(); } else { //设备支持 AR,但需要安装相应软件(这里指手机端的 ARCore 或者 ARKit) if (ARSession.state == ARSessionState.NeedsInstall) { yield return(ARSession.Install()); } isSupportAR = true; OnInitARFinish(); } }
IEnumerator Start() { if ((ARSession.state == ARSessionState.None) || (ARSession.state == ARSessionState.CheckingAvailability)) { Debug.Log("Waiting"); yield return(ARSession.CheckAvailability()); Debug.Log("Done wait"); } if (ARSession.state == ARSessionState.Unsupported) { Debug.Log("NOT ALL RIGHT!!!"); // Start some fallback experience for unsupported devices } else { // Start the AR session Debug.Log("ALL RIGHT!!!"); m_Session.enabled = true; } }
IEnumerator checkAR() { // So, I wanna make sure that the *Play with AR* button only shows // to AR-supported devices // But the problem is that it requires a // And I don't have an AR-unsupported device so I can't test this // *sad noises* if ((ARSession.state == ARSessionState.None) || (ARSession.state == ARSessionState.CheckingAvailability)) { yield return(ARSession.CheckAvailability()); } if (ARSession.state == ARSessionState.Unsupported) { playARBtn.SetActive(false); Globals.supportsAR = false; } else { aRSession.enabled = true; Globals.supportsAR = true; } }
/// <summary> /// Entry point of the whole Unity component; this function starts the AR session /// </summary> private IEnumerator Start() { if (ARSession.state == ARSessionState.None || ARSession.state == ARSessionState.CheckingAvailability) { yield return(ARSession.CheckAvailability()); } if (ARSession.state == ARSessionState.Unsupported) { Debug.LogError("AR Foundation not supported on this device"); } else { // Start the AR Session arSession.enabled = true; Debug.Log("AR Session started"); // Accept any SSL certificate as valid. Because people may self-sign their HTTPS certs we need this. // But for this reason I would not use HTTPS as a means of verification since anyone could spoof the certificate ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true; } }
IEnumerator Start() { arSession.enabled = false; if (ARSession.state == ARSessionState.None || ARSession.state == ARSessionState.CheckingAvailability) { yield return(ARSession.CheckAvailability()); } else if (ARSession.state == ARSessionState.Unsupported) { Debug.Log("ARSessionStartHelper :: ar unsupported"); this.OnFailARSession?.Invoke(); yield break; } if (ARSession.state == ARSessionState.NeedsInstall) { Debug.Log("ARSessionStartHelper :: ar library need install"); this.OnRequestARLibInstall?.Invoke(); yield return(ARSession.Install()); Debug.Log("ARSessionStartHelper :: ar library installed"); } if (ARSession.state == ARSessionState.Ready) { Debug.Log("ARSessionStartHelper :: ar ready"); this.OnReadyAR?.Invoke(); arSession.enabled = true; } yield return(null); }
/// <summary> /// Sets up AR /// Disables the game mode switching button on homescreen if AR is not supported on device /// </summary> IEnumerator SetupAR() { //Disable the button first UIManager.Instance.ARBtn.gameObject.SetActive(false); //AR session GameObject arSessionGO = new GameObject("AR Session"); arSessionGO.AddComponent <ARSession>(); //if AR is not supported on device destroy AR session and exit from coroutine. if ((ARSession.state == ARSessionState.None) || (ARSession.state == ARSessionState.CheckingAvailability)) { yield return(ARSession.CheckAvailability()); } if (ARSession.state == ARSessionState.Unsupported) { Destroy(arSessionGO); yield break; } //AR is supported. Do the rest of the set up UIManager.Instance.ARBtn.gameObject.SetActive(true); arSessionGO.SetActive(false); arSessionGO.AddComponent <ARInputManager>(); //AR session Origin GameObject aRsessionOriginGO = new GameObject("AR Session Origins"); aRsessionOriginGO.SetActive(false); var origin = aRsessionOriginGO.AddComponent <ARSessionOrigin>(); aRRaycastManager = aRsessionOriginGO.AddComponent <ARRaycastManager>(); aRsessionOriginGO.AddComponent <ARPlaneManager>(); //AR Camera GameObject arCamerGO = new GameObject("AR Camera"); arCamerGO.transform.SetParent(aRsessionOriginGO.transform); arCamera = arCamerGO.AddComponent <Camera>(); arCamera.clearFlags = CameraClearFlags.Color; arCamera.backgroundColor = Color.black; arCamera.nearClipPlane = 0.1f; arCamera.farClipPlane = 80; origin.camera = arCamera; var tpd = arCamerGO.AddComponent <TrackedPoseDriver>(); arCamerGO.AddComponent <ARCameraManager>(); arCamerGO.AddComponent <ARCameraBackground>(); tpd.SetPoseSource(TrackedPoseDriver.DeviceType.GenericXRDevice, TrackedPoseDriver.TrackedPose.ColorCamera); //Setting the scale of AR world aRsessionOriginGO.transform.localScale = Vector3.one * AROriginScale; //Adding all AR assets to the list ARAssets.Add(arSessionGO); ARAssets.Add(aRsessionOriginGO); ARAssets.Add(maskPlane); ARAssets.Add(SurfaceNotFoundGraphic); }
private IEnumerator CheckAvailable() { yield return(ARSession.CheckAvailability()); }