private void OnInitError(VuforiaUnity.InitError error) { if (error != VuforiaUnity.InitError.INIT_SUCCESS) { ShowErrorMessage(error); } }
private void SetErrorCode(VuforiaUnity.InitError errorCode) { Debug.LogError("Vuforia initialization failed: " + mErrorText); switch (errorCode) { case VuforiaUnity.InitError.INIT_EXTERNAL_DEVICE_NOT_DETECTED: mErrorText = "Failed to initialize Vuforia because this " + "device is not docked with required external hardware."; break; case VuforiaUnity.InitError.INIT_LICENSE_ERROR_MISSING_KEY: mErrorText = "Vuforia App key is missing. Please get a valid key, " + "by logging into your account at developer.vuforia.com " + "and creating a new project"; break; case VuforiaUnity.InitError.INIT_LICENSE_ERROR_INVALID_KEY: mErrorText = "Invalid Key used. " + "Please make sure you are using a valid Vuforia App Key"; break; case VuforiaUnity.InitError.INIT_LICENSE_ERROR_NO_NETWORK_TRANSIENT: mErrorText = "Unable to contact server. Please try again later."; break; case VuforiaUnity.InitError.INIT_LICENSE_ERROR_NO_NETWORK_PERMANENT: mErrorText = "No network available. Please make sure you are connected to the internet."; break; case VuforiaUnity.InitError.INIT_LICENSE_ERROR_CANCELED_KEY: mErrorText = "This App license key has been cancelled " + "and may no longer be used. Please get a new license key."; break; case VuforiaUnity.InitError.INIT_LICENSE_ERROR_PRODUCT_TYPE_MISMATCH: mErrorText = "Vuforia App key is not valid for this product. Please get a valid key, "+ "by logging into your account at developer.vuforia.com and choosing the "+ "right product type during project creation"; break; #if (UNITY_IPHONE || UNITY_IOS) case VuforiaUnity.InitError.INIT_NO_CAMERA_ACCESS: mErrorText = "Camera Access was denied to this App. \n" + "When running on iOS8 devices, \n" + "users must explicitly allow the App to access the camera.\n" + "To restore camera access on your device, go to: \n" + "Settings > Privacy > Camera > [This App Name] and switch it ON."; break; #endif case VuforiaUnity.InitError.INIT_DEVICE_NOT_SUPPORTED: mErrorText = "Failed to initialize Vuforia because this device is not " + "supported."; break; case VuforiaUnity.InitError.INIT_ERROR: mErrorText = "Failed to initialize Vuforia."; break; } }
public void OnVuforiaInitializationError(VuforiaUnity.InitError initError) { if (initError != VuforiaUnity.InitError.INIT_SUCCESS) { mErrorOccurred = true; mPopUpMsg.SetErrorCode(initError); } }
private void OnInitError(VuforiaUnity.InitError error) { if (error != VuforiaUnity.InitError.INIT_SUCCESS) { Cardboard.SDK.VRModeEnabled = false; // With Cardboard 0.5.0 / 0.5.1, use this line: //Cardboard.SDK.DistortionCorrection = false; // With Cardboard 0.5.2, use this line: (Hope its fine for 0.6.0 as well) Cardboard.SDK.DistortionCorrection = Cardboard.DistortionCorrectionMethod.None; // Show error popup dialog ShowErrorMessage(error); } }
public void OnVuforiaInitializationError(VuforiaUnity.InitError initError) { if (initError != VuforiaUnity.InitError.INIT_SUCCESS) { SetErrorCode(initError); SetErrorOccurred(true); } }
private void LateUpdate() { if (AutoRegionSize && !Is_Child_ImageTarget) { transform.position = ImageTarget.transform.position; transform.localRotation = ImageTarget.transform.localRotation; } var M = transform.localToWorldMatrix; var V = AR_Camera_Vector.transform.worldToLocalMatrix; var P = VuforiaUnity.GetProjectionGL(0, 0, 0); #if !UNITY_EDITOR && !UNITY_STANDALONE tmp00_updt = P.m00; tmp01_updt = P.m01; tmp02_updt = P.m02; if (tmp00_updt != tmp00_init || tmp01_updt != tmp01_init || tmp02_updt != tmp02_init) { StartCoroutine(Start_Initialize()); } if (Screen.orientation == ScreenOrientation.LandscapeRight) { P.m02 *= vuforia_ios_magic; } if (Screen.orientation == ScreenOrientation.LandscapeLeft) { P.m12 *= vuforia_ios_magic; } if (Screen.orientation == ScreenOrientation.Portrait || Screen.orientation == ScreenOrientation.PortraitUpsideDown) { if (reverse_matrix) { P.m02 = -P.m12; P.m12 = -tmp02_updt; } P.m02 /= vuforia_ios_magic; P.m12 *= vuforia_ios_magic; } #endif m_renderer.material.SetMatrix("_MATRIX_MVP", P * V * M); if (mTrackableBehaviour != null && (int)mTrackableBehaviour.CurrentStatus > 1) { m_renderer.material.SetFloat("_Alpha", 1); m_renderer.enabled = true; } else { m_renderer.material.SetFloat("_Alpha", 0); frame_num += 1; if (frame_num > 3) { m_renderer.enabled = false; frame_num = 0; } } if (CheckMarkerPosition || ColorDebugMode) { var boundPoint1 = m_renderer.bounds.min; var boundPoint2 = m_renderer.bounds.max; var boundPoint3 = new Vector3(boundPoint1.x, boundPoint1.y, boundPoint2.z); var boundPoint4 = new Vector3(boundPoint2.x, boundPoint1.y, boundPoint1.z); var screenPos1 = Child_AR_Camera.WorldToScreenPoint(boundPoint1); var screenPos2 = Child_AR_Camera.WorldToScreenPoint(boundPoint2); var screenPos3 = Child_AR_Camera.WorldToScreenPoint(boundPoint3); var screenPos4 = Child_AR_Camera.WorldToScreenPoint(boundPoint4); if (screenPos1.x < 0 || screenPos1.y < 0 || screenPos2.x < 0 || screenPos2.y < 0 || screenPos3.x < 0 || screenPos3.y < 0 || screenPos4.x < 0 || screenPos4.y < 0 || screenPos1.x > CPW || screenPos1.y > CPH || screenPos2.x > CPW || screenPos2.y > CPH || screenPos3.x > CPW || screenPos3.y > CPH || screenPos4.x > CPW || screenPos4.y > CPH) { if (!MarkerIsOUT) { StartCoroutine(Start_MarkerOutOfBounds()); MarkerIsOUT = true; MarkerIsIN = false; } } else { if (!MarkerIsIN) { StartCoroutine(Start_MarkerIsReturned()); MarkerIsIN = true; } MarkerIsOUT = false; } } }
private void Initialize() { var meshFilter = BackgroundPlane.GetComponent <MeshFilter>(); if (VuforiaRenderer.Instance.IsVideoBackgroundInfoAvailable()) { var videoTextureInfo = VuforiaRenderer.Instance.GetVideoTextureInfo(); if (videoTextureInfo.imageSize.x == 0 || videoTextureInfo.imageSize.y == 0) { goto End; } var k_x = videoTextureInfo.imageSize.x / (float)videoTextureInfo.textureSize.x * 0.5f; var k_y = videoTextureInfo.imageSize.y / (float)videoTextureInfo.textureSize.y * 0.5f; m_renderer.material.SetFloat("_KX", k_x); m_renderer.material.SetFloat("_KY", k_y); VideoBackgroundTexure = VuforiaRenderer.Instance.VideoBackgroundTexture as Texture2D; if (!VideoBackgroundTexure || !meshFilter) { goto End; } m_renderer.material.SetTexture("_MainTex", VideoBackgroundTexure); AR_Camera_Vector.transform.parent = ARCamera.transform; AR_Camera_Vector.transform.localPosition = Vector3.zero; AR_Camera_Vector.transform.localScale = new Vector3(1.0f, 1.0f, 1.0f); AR_Camera_Vector.transform.localEulerAngles = new Vector3(0.0f, 180.0f, 180.0f); #if !UNITY_EDITOR && !UNITY_STANDALONE var P = VuforiaUnity.GetProjectionGL(0, 0, 0); tmp00_init = P.m00; tmp01_init = P.m01; tmp02_init = P.m02; if (CameraDevice.Instance.GetCameraDirection() == CameraDevice.CameraDirection.CAMERA_FRONT) { AR_Camera_Vector.transform.localEulerAngles = new Vector3(0.0f, 0.0f, 0.0f); } if (Screen.orientation == ScreenOrientation.LandscapeRight || Screen.orientation == ScreenOrientation.LandscapeLeft) { vuforia_ios_magic = -1.0f; } if (Screen.orientation == ScreenOrientation.Portrait) { if (Application.platform == RuntimePlatform.IPhonePlayer && tmp02_init < 0) { vuforia_ios_magic = -2.0f; } else { vuforia_ios_magic = 1.0f; } if (SystemInfo.deviceModel.Contains("iPhone5,3") || SystemInfo.deviceModel.Contains("iPhone5,4")) { vuforia_ios_magic = -1.0f; } } if (Screen.orientation == ScreenOrientation.PortraitUpsideDown) { if (Application.platform == RuntimePlatform.IPhonePlayer && tmp02_init > 0) { vuforia_ios_magic = 2.0f; } else { vuforia_ios_magic = -1.0f; } if (SystemInfo.deviceModel.Contains("iPhone5,3") || SystemInfo.deviceModel.Contains("iPhone5,4")) { vuforia_ios_magic = 1.0f; } } #endif #if UNITY_EDITOR || UNITY_STANDALONE AR_Camera_Vector.transform.localPosition = new Vector3(0.0f, ImageTarget.GetComponent <ImageTargetBehaviour>().GetSize().x / 240.0f, 0.0f); #else float aspect = (float)videoTextureInfo.imageSize.x / (float)videoTextureInfo.imageSize.y; if (Screen.orientation == ScreenOrientation.Portrait || Screen.orientation == ScreenOrientation.PortraitUpsideDown) { AR_Camera_Vector.transform.localScale = new Vector3(1.0f / aspect, aspect, 1.0f); } #endif End: if (videoTextureInfo.imageSize.x == 0 || videoTextureInfo.imageSize.y == 0 || !VideoBackgroundTexure || !meshFilter) { StartCoroutine(Start_Initialize()); } } else { StartCoroutine(Start_Initialize()); } }
public void SetErrorCode(VuforiaUnity.InitError errorCode) { mCurrentError = new ErrorData(); mCurrentError.Title = "Vuforia Initialization Error"; mCurrentError.Text = ""; Debug.LogError("Vuforia initialization failed: " + errorCode); mErrorcode = errorCode; switch (errorCode) { case VuforiaUnity.InitError.INIT_LICENSE_ERROR_MISSING_KEY: mCurrentError.Text = "Vuforia App key is missing. Please get a valid key, by logging into your account at developer.vuforia.com and creating a new project "; break; #if (UNITY_IPHONE || UNITY_IOS) case VuforiaUnity.InitError.INIT_NO_CAMERA_ACCESS: mCurrentError.Text = "Camera Access was denied to this App. \n" + "When running on iOS8 devices, \n" + "users must explictly allow the App to access the camera.\n" + "To restore camera access on your device, go to: \n" + "Settings > Privacy > Camera > [This App Name] and switch it ON."; break; #endif case VuforiaUnity.InitError.INIT_LICENSE_ERROR_INVALID_KEY: mCurrentError.Text = " Invalid Key used. Please make sure you are using a valid Vuforia App Key"; break; case VuforiaUnity.InitError.INIT_LICENSE_ERROR_NO_NETWORK_TRANSIENT: mCurrentError.Text = "Unable to contact server. Please try again later."; break; case VuforiaUnity.InitError.INIT_LICENSE_ERROR_NO_NETWORK_PERMANENT: mCurrentError.Text = "No network available. Please make sure you are connected to the Internet."; break; case VuforiaUnity.InitError.INIT_LICENSE_ERROR_CANCELED_KEY: mCurrentError.Text = "This app license key has been canceled and may no longer be used. Please get a new license key"; break; case VuforiaUnity.InitError.INIT_ERROR: mCurrentError.Text = "Failed to initialize Vuforia."; break; case VuforiaUnity.InitError.INIT_LICENSE_ERROR_PRODUCT_TYPE_MISMATCH: mCurrentError.Text = "Vuforia App key is not valid for this product. Please get a valid key, " + "by logging into your account at developer.vuforia.com and choosing the " + "right product type during project creation"; break; } }