public void OnPreCull()
 {
     if (this.mDeactivatedHideBehaviours != null)
     {
         this.SetPlanesRenderingActive(true);
         this.mDeactivatedHideBehaviours.Clear();
         HideExcessAreaAbstractBehaviour[] array = this.mHideBehaviours;
         for (int i = 0; i < array.Length; i++)
         {
             HideExcessAreaAbstractBehaviour hideExcessAreaAbstractBehaviour = array[i];
             if (hideExcessAreaAbstractBehaviour != null && hideExcessAreaAbstractBehaviour.gameObject != this.mGameObject && hideExcessAreaAbstractBehaviour.IsPlanesRenderingActive())
             {
                 hideExcessAreaAbstractBehaviour.SetPlanesRenderingActive(false);
                 this.mDeactivatedHideBehaviours.Add(hideExcessAreaAbstractBehaviour);
             }
         }
     }
 }
Esempio n. 2
0
        private void UpdateVideoBackgroundEnabled()
        {
            DigitalEyewearARController instance = DigitalEyewearARController.Instance;
            Camera            primaryCamera     = instance.PrimaryCamera;
            Camera            secondaryCamera   = instance.SecondaryCamera;
            GameObject        gameObject        = UnityEngine.Object.FindObjectOfType <VuforiaAbstractBehaviour>().gameObject;
            List <GameObject> list = new List <GameObject>
            {
                gameObject
            };

            if (primaryCamera != null)
            {
                list.Add(primaryCamera.gameObject);
            }
            if (secondaryCamera != null)
            {
                list.Add(secondaryCamera.gameObject);
            }
            HashSet <VideoBackgroundAbstractBehaviour> hashSet = new HashSet <VideoBackgroundAbstractBehaviour>();

            using (List <GameObject> .Enumerator enumerator = list.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    VideoBackgroundAbstractBehaviour[] componentsInChildren = enumerator.Current.GetComponentsInChildren <VideoBackgroundAbstractBehaviour>(true);
                    for (int i = 0; i < componentsInChildren.Length; i++)
                    {
                        VideoBackgroundAbstractBehaviour item = componentsInChildren[i];
                        hashSet.Add(item);
                    }
                }
            }
            using (HashSet <VideoBackgroundAbstractBehaviour> .Enumerator enumerator2 = hashSet.GetEnumerator())
            {
                while (enumerator2.MoveNext())
                {
                    enumerator2.Current.enabled = this.mVideoBackgroundEnabled;
                }
            }
            HashSet <BackgroundPlaneAbstractBehaviour> hashSet2 = new HashSet <BackgroundPlaneAbstractBehaviour>();

            using (List <GameObject> .Enumerator enumerator = list.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    BackgroundPlaneAbstractBehaviour[] componentsInChildren2 = enumerator.Current.GetComponentsInChildren <BackgroundPlaneAbstractBehaviour>(true);
                    for (int i = 0; i < componentsInChildren2.Length; i++)
                    {
                        BackgroundPlaneAbstractBehaviour item2 = componentsInChildren2[i];
                        hashSet2.Add(item2);
                    }
                }
            }
            using (HashSet <BackgroundPlaneAbstractBehaviour> .Enumerator enumerator3 = hashSet2.GetEnumerator())
            {
                while (enumerator3.MoveNext())
                {
                    enumerator3.Current.GetComponent <Renderer>().GetComponent <Renderer>().enabled = this.mVideoBackgroundEnabled;
                }
            }
            HashSet <HideExcessAreaAbstractBehaviour> hashSet3 = new HashSet <HideExcessAreaAbstractBehaviour>();

            using (List <GameObject> .Enumerator enumerator = list.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    HideExcessAreaAbstractBehaviour[] componentsInChildren3 = enumerator.Current.GetComponentsInChildren <HideExcessAreaAbstractBehaviour>(true);
                    for (int i = 0; i < componentsInChildren3.Length; i++)
                    {
                        HideExcessAreaAbstractBehaviour item3 = componentsInChildren3[i];
                        hashSet3.Add(item3);
                    }
                }
            }
            using (HashSet <HideExcessAreaAbstractBehaviour> .Enumerator enumerator4 = hashSet3.GetEnumerator())
            {
                while (enumerator4.MoveNext())
                {
                    enumerator4.Current.enabled = this.mVideoBackgroundEnabled;
                }
            }
            instance.SetMode(this.mVideoBackgroundEnabled ? Device.Mode.MODE_AR : Device.Mode.MODE_VR);
            VuforiaARController.Instance.CameraConfiguration.SetSkewFrustum(this.mVideoBackgroundEnabled);
        }
        private void ConfigureView()
        {
            EyewearDevice eyewearDevice = Device.Instance as EyewearDevice;
            bool          arg_4E_0      = Device.Instance.IsViewerActive() || (eyewearDevice != null && eyewearDevice.IsDualDisplay());
            bool          flag          = this.mCentralAnchorPoint != base.VuforiaBehaviour.transform && this.mCentralAnchorPoint != null;

            if (!arg_4E_0)
            {
                if (this.mSecondaryCamera && this.mSecondaryCamera.enabled)
                {
                    this.mPrimaryCameraOriginalRect      = new Rect(this.mPrimaryCamera.rect);
                    this.mSecondaryCameraOriginalRect    = new Rect(this.mSecondaryCamera.rect);
                    this.mSecondaryCamera.enabled        = false;
                    this.mSecondaryCameraDisabledLocally = true;
                    this.DisableDistortionRendering();
                    Rect rect = new Rect(0f, 0f, 1f, 1f);
                    this.mPrimaryCamera.rect        = rect;
                    this.mPrimaryCamera.fieldOfView = 60f;
                }
            }
            else
            {
                if (this.mSecondaryCamera && !this.mSecondaryCamera.enabled)
                {
                    if (!flag)
                    {
                        this.mSecondaryCamera.enabled = true;
                    }
                    if (this.mSecondaryCameraDisabledLocally)
                    {
                        this.mSecondaryCameraDisabledLocally = false;
                        this.mPrimaryCamera.rect             = this.mPrimaryCameraOriginalRect;
                        this.mSecondaryCamera.rect           = this.mSecondaryCameraOriginalRect;
                    }
                }
                if (!flag && this.mSecondaryCamera == null)
                {
                    this.mPrimaryCamera.name = "StereoCameraLeft";
                    this.mPrimaryCamera.rect = new Rect(0f, 0f, 0.5f, 1f);
                    this.mSecondaryCamera    = UnityEngine.Object.Instantiate <Camera>(this.mPrimaryCamera);
                    this.mSecondaryCamera.transform.parent        = this.mPrimaryCamera.transform.parent;
                    this.mSecondaryCamera.transform.localPosition = this.mPrimaryCamera.transform.localPosition;
                    this.mSecondaryCamera.transform.localRotation = this.mPrimaryCamera.transform.localRotation;
                    this.mSecondaryCamera.transform.localScale    = this.mPrimaryCamera.transform.localScale;
                    this.mSecondaryCamera.name = "StereoCameraRight";
                    this.mSecondaryCamera.rect = new Rect(0.5f, 0f, 0.5f, 1f);
                    BackgroundPlaneAbstractBehaviour componentInChildren = this.mSecondaryCamera.GetComponentInChildren <BackgroundPlaneAbstractBehaviour>();
                    if (componentInChildren != null)
                    {
                        UnityEngine.Object.Destroy(componentInChildren.gameObject);
                    }
                    VideoBackgroundAbstractBehaviour component = this.mSecondaryCamera.GetComponent <VideoBackgroundAbstractBehaviour>();
                    if (component != null)
                    {
                        component.DisconnectFromBackgroundBehaviour();
                    }
                }
            }
            if (this.mPrimaryCamera && VuforiaARController.IsValidPrimaryCamera(this.mPrimaryCamera))
            {
                this.mPrimaryCamera.transform.localRotation = Quaternion.identity;
                this.mPrimaryCamera.transform.localScale    = Vector3.one;
                if (this.mSecondaryCamera && (flag || this.mSecondaryCamera.enabled) && VuforiaARController.IsValidSecondaryCamera(this.mSecondaryCamera))
                {
                    this.mSecondaryCamera.transform.localRotation = Quaternion.identity;
                    this.mSecondaryCamera.transform.localScale    = Vector3.one;
                    if (flag)
                    {
                        this.CameraConfiguration = new ExternalStereoCameraConfiguration(this.mPrimaryCamera, this.mSecondaryCamera);
                        Debug.Log("Creating an External Stereo Camera Configuration (Check for reflection)");
                    }
                    else if (eyewearDevice != null)
                    {
                        this.CameraConfiguration = new DedicatedEyewearCameraConfiguration(this.mPrimaryCamera, this.mSecondaryCamera);
                        Debug.Log("Creating a Dedicated Eyewear Camera Configuration (Check for reflection)");
                    }
                    else
                    {
                        this.CameraConfiguration = new StereoViewerCameraConfiguration(this.mPrimaryCamera, this.mSecondaryCamera, this.mCameraOffset, this.mDistortionRenderingMode > DistortionRenderingMode.None);
                        Debug.Log("Creating a Stereo Viewer Camera Configuration (Check for reflection)");
                        this.EnableDistortionRendering();
                    }
                }
                else
                {
                    this.CameraConfiguration = new MonoCameraConfiguration(this.mPrimaryCamera);
                    Debug.Log("Creating a Mono Camera Configuration (Check for reflection)");
                }
            }
            else
            {
                this.CameraConfiguration = new NullCameraConfiguration();
                Debug.Log("Creating a Null Camera Configuration (Check for reflection)");
            }
            this.mVuforiaBehaviour.InitCameraConfiguration();
            this.CameraConfiguration.Init();
            if (this.mPrimaryCamera != null)
            {
                HideExcessAreaAbstractBehaviour component2 = this.mPrimaryCamera.GetComponent <HideExcessAreaAbstractBehaviour>();
                if (component2)
                {
                    component2.OnConfigurationChanged();
                }
            }
            if (this.mSecondaryCamera != null)
            {
                HideExcessAreaAbstractBehaviour component3 = this.mSecondaryCamera.GetComponent <HideExcessAreaAbstractBehaviour>();
                if (component3)
                {
                    component3.OnConfigurationChanged();
                }
            }
        }