Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        bool didChange;

        if (Time.time - lastUpdateTime < 1.0f / captureRateFps)
        {
            return;
        }
        else
        {
            lastUpdateTime = Time.time;
        }



        // Capture the desktop
        Texture2D desktopTexture = desktopCapture1.GetWindowTexture(out didChange);

        desktopObject.transform.localScale = new Vector3(desktopCapture1.desktopWidth * windowScale, 0.1f, desktopCapture1.desktopHeight * windowScale);
        if (didChange)
        {
            desktopObject.transform.GetComponent <Renderer>().material.mainTexture = desktopTexture;
        }

        // Gets information about position and icon of the cursor so you can render it onto the captured surfaces
        WindowCapture.UpdateCursorInfo();

        // Capture each window
        foreach (IntPtr key in windowsRendering.Keys)
        {
            WindowCapture window       = windowsRendering[key];
            GameObject    windowObject = windowObjects[key];

            if (windowObject == null)
            {
                continue;
            }

            Texture2D windowTexture = window.GetWindowTexture(out didChange);
            if (didChange)
            {
                windowObject.GetComponent <Renderer>().material.mainTexture = windowTexture;
            }
            windowObject.transform.localScale = new Vector3(window.windowWidth * windowScale, 0.1f, window.windowHeight * windowScale);
        }

        // Poll for new windows
        if (Time.time - lastPollWindowsTime < 1.0f / windowPollPerSecond)
        {
            return;
        }
        else
        {
            lastPollWindowsTime = Time.time;
            // calls OnAddWindow or OnRemoveWindow above if any windows have been added or removed
            captureManager.Poll();
        }
    }
Beispiel #2
0
    // Update is called once per frame
    void Update()
    {
        bool didChange;

        // Capture each window
        foreach (IntPtr key in windowsRendering.Keys)
        {
            WindowCapture window       = windowsRendering[key];
            GameObject    windowObject = windowObjects[key];

            if (windowObject == null)
            {
                continue;
            }

            windowTexture = window.GetWindowTexture(out didChange);
            if (didChange)
            {
                //windowObject.GetComponent<Renderer>().material.mainTexture = windowTexture;
                foreach (Material mat in mats)
                {
                    mat.mainTexture = windowTexture;
                }
            }
            windowTexture = null;
            //windowObject.transform.localScale = new Vector3(window.windowWidth * windowScale, 0.1f, window.windowHeight * windowScale);
        }

        // Poll for new windows
        if (windowFound == false)
        {
            if (count >= 5)
            {
                windowFound = true;
            }
            if (Time.time - lastPollWindowsTime < 1.0f / windowPollPerSecond)
            {
                return;
            }
            else
            {
                count++;
                lastPollWindowsTime = Time.time;
                // calls OnAddWindow or OnRemoveWindow above if any windows have been added or removed
                captureManager.Poll();
            }
        }
        if (!actualWindowFound)
        {
            foreach (Material mat in mats)
            {
                mat.mainTexture = noSignalTex;
            }
        }
    }
Beispiel #3
0
    // Update is called once per frame
    void Update()
    {
        float curT = Time.time;

        if (curT - lastUpdateTime > 1.0f / captureRateFps)
        {
            count++;
            //start a thread to execute window update Parallel.ForEach loop
            //workerThread = new Thread(WorkerThread);
            //workerThread.Start();
            Task t = Task.Factory.StartNew(() => {
                Parallel.ForEach(windowsRendering.Keys, key => this.UpdateWindowTextures(key));
            });
            lastUpdateTime = curT;
        }

        #region Poll for New Windows
        // Poll for new windows
        //float curT = Time.time;
        if (curT - lastPollWindowsTime > 1.0f / windowPollPerSecond || pollNow)
        {
            // calls OnAddWindow or OnRemoveWindow above if any windows have been added or removed
            StartCoroutine(captureManager.Poll());
            lastPollWindowsTime = curT;
        }
        #endregion

        // // Creating a Chromium capture Window
        #region Chromium

        /*
         * Texture2D chromiumTexture = chromiumCapture.GetChromiumTexture(out didChange);
         * if (didChange)
         * {
         *  chromiumObject.GetComponent<Renderer>().material.mainTexture = chromiumTexture;
         * }
         * chromiumObject.transform.localScale = new Vector3(chromiumTexture.width * windowScale, 0.1f, chromiumTexture.height * windowScale);
         *
         *
         * if (Time.frameCount == 400)
         * {
         *  chromiumCapture.SetUrl("http://reddit.com");
         * }
         *
         * if (Time.time - lastUpdateTime < 1.0f / captureRateFps)
         * {
         *  return;
         * }
         * else
         * {
         *  lastUpdateTime = Time.time;
         * }*/
        #endregion

        #region Non-Threaded

        /*
         * // Capture each window - Non Job System
         * foreach (IntPtr key in windowsRendering.Keys)
         * {
         *  WindowCapture window = windowsRendering[key];
         *  GameObject windowObject = windowObjects[key];
         *
         *  if (windowObject == null)
         *  {
         *      continue;
         *  }
         *  Texture2D windowTexture = window.GetWindowTexture(out didChange);
         *  if (didChange)
         *  {
         *      windowObject.GetComponent<Renderer>().material.mainTexture = windowTexture;
         *  }
         *  windowObject.transform.localScale = new Vector3(window.windowWidth * windowScale, 0.1f, window.windowHeight * windowScale);
         * }*/
        #endregion
    }
    // Update is called once per frame
    void Update()
    {
        bool didChange;

        /*
         * Texture2D chromiumTexture = chromiumCapture.GetChromiumTexture(out didChange);
         * if (didChange)
         * {
         * chromiumObject.GetComponent<Renderer>().material.mainTexture = chromiumTexture;
         * }
         * chromiumObject.transform.localScale = new Vector3(chromiumTexture.width * windowScale, 0.1f, chromiumTexture.height * windowScale);
         *
         *
         * if (Time.frameCount == 400)
         * {
         * chromiumCapture.SetUrl("http://reddit.com");
         * }
         *
         * if (Time.time - lastUpdateTime < 1.0f / captureRateFps)
         * {
         * return;
         * }
         * else
         * {
         * lastUpdateTime = Time.time;
         * }
         */


        // Capture the desktop
        Texture2D desktopTexture = desktopCapture1.GetWindowTexture(out didChange);

        desktopObject.transform.localScale = new Vector3(desktopCapture1.desktopWidth * windowScale, 0.1f, desktopCapture1.desktopHeight * windowScale);
        if (didChange)
        {
            desktopObject.transform.GetComponent <Renderer>().material.mainTexture = desktopTexture;
        }

        // Gets information about position and icon of the cursor so you can render it onto the captured surfaces
        WindowCapture.UpdateCursorInfo();

        Profiler.BeginSample("test");
        // Capture each window
        foreach (IntPtr key in windowsRendering.Keys)
        {
            Debug.Log("+");
            WindowCapture window       = windowsRendering[key];
            GameObject    windowObject = windowObjects[key];

            if (windowObject == null)
            {
                continue;
            }

            Texture2D windowTexture = window.GetWindowTexture(out didChange);
            if (didChange)
            {
                windowObject.GetComponent <Renderer>().material.mainTexture = windowTexture;
            }
            windowObject.transform.localScale = new Vector3(window.windowWidth * windowScale, 0.1f, window.windowHeight * windowScale);
        }
        Debug.Log("-");
        Profiler.EndSample();
        // Poll for new windows
        if (Time.time - lastPollWindowsTime < 1.0f / windowPollPerSecond)
        {
            return;
        }
        else
        {
            lastPollWindowsTime = Time.time;
            // calls OnAddWindow or OnRemoveWindow above if any windows have been added or removed
            captureManager.Poll();
        }
    }