private void Start() { this.mStarted = true; VuforiaARController.Instance.RegisterVideoBgEventHandler(this); VuforiaAbstractBehaviour vuforiaAbstractBehaviour = UnityEngine.Object.FindObjectOfType <VuforiaAbstractBehaviour>(); this.mStereoCameras = vuforiaAbstractBehaviour.GetComponentsInChildren <Camera>(); if (this.mStereoCameras.Length != 2) { Debug.LogError("There must be two cameras"); this.mStereoCameras = null; return; } if (this.mSingleTexture) { this.mMeshes = new GameObject[1]; this.mMeshes[0] = this.CreateMeshGameObject(); this.mTextures = new RenderTexture[1]; } else { this.mMeshes = new GameObject[2]; this.mMeshes[0] = this.CreateMeshGameObject(); this.mMeshes[1] = this.CreateMeshGameObject(); this.mTextures = new RenderTexture[2]; } if (this.mVideoBackgroundChanged) { this.mVideoBackgroundChanged = false; this.OnVideoBackgroundConfigChanged(); } this.OnEnable(); }
private void SetViewer(bool viewerPresent) { VuforiaAbstractBehaviour vuforiaAbstractBehaviour = UnityEngine.Object.FindObjectOfType <VuforiaAbstractBehaviour>(); if (vuforiaAbstractBehaviour != null && this.mDigitalEyewearBehaviour != null) { if (viewerPresent) { this.mDigitalEyewearBehaviour.SetEyewearType(DigitalEyewearARController.EyewearType.VideoSeeThrough); } else { this.mDigitalEyewearBehaviour.SetEyewearType(DigitalEyewearARController.EyewearType.None); } if (viewerPresent && this.mViewerParameters != null) { if (this.mDigitalEyewearBehaviour.GetStereoCameraConfig() != this.mStereoFramework) { this.mDigitalEyewearBehaviour.SetStereoCameraConfiguration(this.mStereoFramework); } if (Device.Instance.GetSelectedViewer() != this.mViewerParameters) { Device.Instance.SelectViewer(this.mViewerParameters); } if (this.mStereoFramework != DigitalEyewearARController.StereoFramework.Vuforia) { Camera[] componentsInChildren = vuforiaAbstractBehaviour.GetComponentsInChildren <Camera>(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].gameObject.SetActive(false); } if (this.mDigitalEyewearBehaviour.CentralAnchorPoint != this.mCentralAnchorPoint) { this.mDigitalEyewearBehaviour.SetCentralAnchorPoint(this.mCentralAnchorPoint); } if (this.mDigitalEyewearBehaviour.PrimaryCamera != this.mLeftCameraOfExternalSDK) { this.mDigitalEyewearBehaviour.PrimaryCamera = this.mLeftCameraOfExternalSDK; } if (this.mDigitalEyewearBehaviour.SecondaryCamera != this.mRightCameraOfExternalSDK) { this.mDigitalEyewearBehaviour.SecondaryCamera = this.mRightCameraOfExternalSDK; } } } if (!viewerPresent && this.mStereoFramework != DigitalEyewearARController.StereoFramework.Vuforia) { Camera[] componentsInChildren = vuforiaAbstractBehaviour.GetComponentsInChildren <Camera>(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].gameObject.SetActive(true); } Transform transform = vuforiaAbstractBehaviour.gameObject.transform; Camera componentInChildren = vuforiaAbstractBehaviour.GetComponentInChildren <Camera>(); if (this.mDigitalEyewearBehaviour.CentralAnchorPoint != transform) { this.mDigitalEyewearBehaviour.SetCentralAnchorPoint(transform); } if (this.mDigitalEyewearBehaviour.PrimaryCamera != componentInChildren) { this.mDigitalEyewearBehaviour.PrimaryCamera = componentInChildren; } if (this.mDigitalEyewearBehaviour.SecondaryCamera != null) { this.mDigitalEyewearBehaviour.SecondaryCamera = null; } } if (Device.Instance.IsViewerActive() != viewerPresent) { this.mDigitalEyewearBehaviour.SetViewerActive(viewerPresent); } } }