Exemple #1
0
        /// <summary>
        /// Update is called once each frame, if the MonoBehaviour is enabled.
        /// </summary>
        void Update()
        {
            if (_trackerPlugin != null)
            {
                Camera renderingCamera = _renderingCamera;

                if (renderingCamera == null)
                {
                    renderingCamera = Camera.main;
                }

                _trackerPlugin.SetupRenderingCamera(renderingCamera.nearClipPlane, renderingCamera.farClipPlane);

                // Update tracking
                _trackerPlugin.UpdateTracking();

                // Apply projection matrix
                if (_applyProjection)
                {
                    renderingCamera.projectionMatrix = _trackerPlugin.GetProjectionMatrix();
                }
                else
                {
                    renderingCamera.ResetProjectionMatrix();
                }

                // Take a copy of the detected trackables
                ProcessNewTrackables();

                _currentTrackingMethod.ProcessFrame();

                // Apply texture to background renderer
                Texture texture = _trackerPlugin.GetTrackingTexture();

                if (_background != null && texture != null)
                {
                    _background.material.mainTexture = texture;
                }
            }
        }