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();
        }
        /// <summary>
        /// When this game object is destroyed, it unregisters itself as event handler
        /// </summary>
        void OnDestroy()
        {
            VuforiaAbstractBehaviour vuforiaBehaviour = (VuforiaAbstractBehaviour)FindObjectOfType(typeof(VuforiaAbstractBehaviour));

            if (vuforiaBehaviour)
            {
                vuforiaBehaviour.UnregisterVuforiaInitErrorCallback(OnVuforiaInitializationError);
            }
        }
        void Awake()
        {
            // Check for an initialization error on start.
            VuforiaAbstractBehaviour vuforiaBehaviour = (VuforiaAbstractBehaviour)FindObjectOfType(typeof(VuforiaAbstractBehaviour));

            if (vuforiaBehaviour)
            {
                vuforiaBehaviour.RegisterVuforiaInitErrorCallback(OnVuforiaInitializationError);
            }
        }
Beispiel #4
0
 private void UnregisterCamera(VuforiaAbstractBehaviour bhvr)
 {
     if (bhvr == this.mVuforiaBehaviour)
     {
         bhvr.AwakeEvent       -= new Action(this.Awake);
         this.mVuforiaBehaviour = null;
         return;
     }
     Debug.LogWarning("Tried to unregister camera which hasn't been registered before");
 }
Beispiel #5
0
 private void RegisterCamera(VuforiaAbstractBehaviour bhvr)
 {
     if (this.mVuforiaBehaviour != null)
     {
         Debug.LogError("It's not possible to have two ARCameras at the same time");
         return;
     }
     this.mVuforiaBehaviour        = bhvr;
     bhvr.AwakeEvent              += new Action(this.Awake);
     bhvr.OnEnableEvent           += new Action(this.OnEnable);
     bhvr.StartEvent              += new Action(this.Start);
     bhvr.UpdateEvent             += new Action(this.Update);
     bhvr.OnLevelWasLoadedEvent   += new Action(this.OnLevelWasLoaded);
     bhvr.OnApplicationPauseEvent += new Action <bool>(this.OnApplicationPause);
     bhvr.OnDisableEvent          += new Action(this.OnDisable);
     bhvr.OnDestroyEvent          += new Action(this.OnDestroy);
 }
 internal void OnVuforiaInitialized()
 {
     if (this.mAutoInitTracker)
     {
         bool flag = false;
         VuforiaAbstractBehaviour vuforiaAbstractBehaviour = UnityEngine.Object.FindObjectOfType <VuforiaAbstractBehaviour>();
         if (VuforiaARController.Instance.HasStarted && vuforiaAbstractBehaviour != null)
         {
             vuforiaAbstractBehaviour.enabled = false;
             flag = true;
         }
         this.InitSmartTerrainTracker();
         if (flag)
         {
             vuforiaAbstractBehaviour.enabled = true;
         }
     }
 }
        internal void OnVuforiaInitialized()
        {
            bool flag = false;
            VuforiaAbstractBehaviour vuforiaAbstractBehaviour = UnityEngine.Object.FindObjectOfType <VuforiaAbstractBehaviour>();

            if (VuforiaARController.Instance.HasStarted && vuforiaAbstractBehaviour != null)
            {
                vuforiaAbstractBehaviour.enabled = false;
                flag = true;
            }
            if (TrackerManager.Instance.GetTracker <TextTracker>() == null)
            {
                TrackerManager.Instance.InitTracker <TextTracker>();
            }
            if (flag)
            {
                vuforiaAbstractBehaviour.enabled = true;
            }
        }
Beispiel #8
0
        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);
                }
            }
        }