// Update is called once per frame
        void Update()
        {
            if (!ready)
            {
                if (webcam.texture)
                {
                    // Set preview image target
                    image.texture = webcam.texture;

                    // update sendTexture with pixels from webcamTexture
                    sendTexture.SetPixels(webcam.texture.GetPixels());

                    // Set send texture
                    sender.SetSourceTexture(sendTexture);

                    // Mark as ready
                    ready = true;
                }
            }
            else
            {
                // update sendTexture with pixels from webcamTexture
                sendTexture.SetPixels(webcam.texture.GetPixels());
            }
        }
Example #2
0
        private void Start()
        {
            if (!SystemInfo.supportsImageEffects)
            {
                print("System doesn't support image effects");
                enabled = false;
                return;
            }
            if (shader == null || !shader.isSupported)
            {
                enabled = false;
                print("Shader " + shader.name + " is not supported");
                return;
            }

            camera = GetComponent <Camera>();
            // turn on depth rendering for the camera so that the shader can access it via _CameraDepthTexture
            camera.depthTextureMode = DepthTextureMode.Depth;

            sender = GetComponent <TextureSender>();

            sendTexture = new Texture2D((int)camera.targetTexture.width, (int)camera.targetTexture.height);

            sender.SetSourceTexture(sendTexture);
        }
        // Use this for initialization
        void Start()
        {
            camera = GetComponent <Camera>();
            sender = GetComponent <TextureSender>();

            sendTexture = new Texture2D((int)camera.targetTexture.width, (int)camera.targetTexture.height);

            sender.SetSourceTexture(sendTexture);
        }
Example #4
0
        // Use this for initialization
        void Start()
        {
            camera = GetComponent <Camera>();
            sender = GetComponent <TextureSender>();
            Debug.Log("camera.targetTexture.width");
            Debug.Log(camera.targetTexture.width);

            sendTexture = new Texture2D((int)camera.targetTexture.width, (int)camera.targetTexture.width);

            // Set send texture
            sender.SetSourceTexture(sendTexture);
        }
        // Use this for initialization
        void Start()
        {
            videoPlayer = GetComponent <VideoPlayer>();
            sender      = GetComponent <TextureSender>();

            sendTexture  = new Texture2D((int)videoPlayer.clip.width, (int)videoPlayer.clip.height);
            videoTexture = new RenderTexture((int)videoPlayer.clip.width, (int)videoPlayer.clip.height, 24);

            // Set send texture
            sender.SetSourceTexture(sendTexture);

            videoPlayer.renderMode    = VideoRenderMode.RenderTexture;
            videoPlayer.targetTexture = videoTexture;

            videoPlayer.Prepare();
            videoPlayer.Play();
        }
        // Update is called once per frame
        void Update()
        {
            if (videoPlayer.isPlaying)
            {
                RenderTexture.active = videoTexture;
                sendTexture.ReadPixels(new Rect(0, 0, videoTexture.width, videoTexture.height), 0, 0, false);

                // Set preview image target
                image.texture = videoTexture;

                // update sendTexture with pixels from webcamTexture
                // sendTexture.SetPixels(sendTexture.GetPixels());

                // Set send texture
                sender.SetSourceTexture(sendTexture);
            }
            else
            {
                videoPlayer.Play();
            }
        }